onizukaspm / json-simple

Automatically exported from code.google.com/p/json-simple
Apache License 2.0
0 stars 0 forks source link

java.util.Date not well json formatted #58

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Passing a Date to toJSONString() gives : [{"myField":Wed Oct 26 18:58:31 CEST 
2011}]

Which is not a syntactically valid.

It should be : [{"myField":"Wed Oct 26 18:58:31 CEST 2011"}]

Using v1.1

Original issue reported on code.google.com by pablo.qu...@gmail.com on 26 Oct 2011 at 5:00

GoogleCodeExporter commented 9 years ago
You should use String.valueOf() or String.toString() to convert date to string 
before putting it to a JSON object or array. See the following link for details:
http://code.google.com/p/json-simple/wiki/MappingBetweenJSONAndJavaEntities

Original comment by fangyid...@gmail.com on 29 Nov 2011 at 2:52

GoogleCodeExporter commented 9 years ago

Original comment by jon.cham...@gmail.com on 10 Aug 2013 at 4:55