Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
possum16365y@jimshorts After I changed that property‘s name, the string remained intact after JSON.parse.
-
jimshorts145y@possum right and im telling you that's not the default behavior of JSON.parse out of the box. I dunno what codebase you're working in, but it sounds like theres a modification living somewhere.
> var date = new Date()
undefined
> date
2019-07-06T07:36:16.763Z
> var obj = JSON.stringify({"timestamp": date})
undefined
> obj
'{"timestamp":"2019-07-06T07:36:16.763Z"}'
> JSON.parse(obj)
{ timestamp: '2019-07-06T07:36:16.763Z' } -
possum16365y@jimshorts Yeah right, I was pretty surprised, too.
It‘s an Electron application, the only addition to JS itself is jQuery (that probably won‘t affect the JSON methods) -
jimshorts145y@possum well I'd love more info because this is starting to look like a problem for stack overflow and not a rant ;). Feel free to post a link to the repo / offending code. You're not passing in a reviver to JSON.parse() are you?
-
possum16365y@jimshorts nah I‘m just ranting, and it‘s my own local code that‘s not on any repo. I‘ll look the issue up too, I was just annoyed by that yesterday.
Related Rants
So I had this JSON thingy, where I named the property containing a datetime string "timestamp".
For some reason, JS decided to convert that into a unix timestamp int on parse. Thx for nothing.
rant
timestamp
json
javascript
js