duckfly-tw / json-simple

JSON.simple - A simple Java toolkit for JSON
https://code.google.com/p/json-simple/
Apache License 2.0
0 stars 0 forks source link

putting a Date into a JSONObject #3

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. putting a Date-object into a JSONObject

What is the expected output? What do you see instead?
I expected a String representation of that Date, but I get it without
quotes, so the JSON is not valid.

What version of the product are you using? On what operating system?
version 1.1 of json-simple

To fix it, I have to "convert" the date by toString().

Original issue reported on code.google.com by dief...@gmail.com on 20 Apr 2009 at 1:33

GoogleCodeExporter commented 9 years ago
Here's the mapping between JSON and Java entities:
http://code.google.com/p/json-simple/wiki/MappingBetweenJSONAndJavaEntities

Basically, you need to follow the mapping to get valid JSON strings.

Original comment by fangyid...@gmail.com on 20 Apr 2009 at 1:45

GoogleCodeExporter commented 9 years ago

Original comment by fangyid...@gmail.com on 21 Apr 2009 at 4:51

GoogleCodeExporter commented 9 years ago
I disagree with the current behaviour. The library should either automatically 
quote
what toString() returns or not accept unrecognized objects at all. Silently 
producing
broken JSON is the worst option of all IMHO.

Original comment by martin.p...@gmail.com on 10 Aug 2009 at 1:34

GoogleCodeExporter commented 9 years ago
writeJSONString(Object) writing an unquoted toString() is a disaster.  I agree 
with martin, silently producing broken JSON is the worst option, and the 
default behavior.

Original comment by ober...@civicscience.com on 4 Mar 2014 at 6:30