Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Stringify and parse an object with a date string returns an object #105

Open
Ekman opened this issue Nov 22, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@Ekman
Copy link

Ekman commented Nov 22, 2024

Describe the bug

If I stringify and then parse an object with a date string, I get a date object back.

Steps to reproduce the behavior

Consider this script:

import { stringify, parse } from 'telejson'

interface Foo {
    readonly date: string
}

const foo: Foo = { date: '2024-10-10T10:10:10Z' }

const fooStringified = stringify(foo)
console.log(fooStringified)

const fooParsed = parse(fooStringified)
console.log(fooParsed)
console.log(typeof fooParsed.date) // this is a Date but I expect a string

Run it and you will get the output:

{"date":"_date_2024-10-10T10:10:10Z"}
{ date: 2024-10-10T10:10:10.000Z }
object

Expected behavior

I expect the data integrity to be upheld. Meaning, if I serialize a string I expect a string in return. Nothing else.

Screenshots and/or logs

Environment

  • telejson version 7.2.0.

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant