Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON Parse Date Formats?

Am I correct in assuming that I have to MANUALLY convert Json-encoded date strings to date objects in my client code?

Coming from C#, I took for granted that this was happening automatically, but I guess that was .NET.

Is there a built in mechanism for getting native javascript types from a Json string (for dates, ints, etc.)?

Thanks.

like image 742
Scott Klarenbach Avatar asked Jun 17 '10 17:06

Scott Klarenbach


2 Answers

The JSON spec does not define a date data type. That is left up to you.

See Section A.8: http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf

like image 83
ChaosPandion Avatar answered Sep 28 '22 17:09

ChaosPandion


JSON does not have a standard date type. There are various libraries (including .NET) with incompatible extensions for representing it.

like image 45
Matthew Flaschen Avatar answered Sep 28 '22 19:09

Matthew Flaschen