Closed GoogleCodeExporter closed 9 years ago
Most other JSON parsers want quoted keys...
{"myMap":{"class":"java.util.HashMap","pipote":56}}
Is the valid JSON that any parser would understand.
The Json class includes the class name so that it knows what type of Map to
instantiate while deserializing. It doesn't write the class name for the list
because it only knows ArrayList.
Or did I misunderstand?
Original comment by email.ne...@gmail.com
on 22 Oct 2012 at 3:09
[deleted comment]
I just happened to bump into this "bug" tonight myself. It is solvable by
instantiating json by: new Json(OutputType.json). From the docs:
"/** Like JSON, but names and values are only quoted if necessary. */
minimal;", which is the default behavior. I think that the default behavior
should be regular json, and that users may specify minimal if they really need
it.
Original comment by kjetil...@gmail.com
on 23 Oct 2012 at 11:15
Well, it seems there is a way to export normal JSON by using
json.setOutputType(OutputType.json), but it is not enable by default, I
believe the default output should be normal JSON and the others should be
optional.
Also, is there a way to not export the Map class as one entry of the map?, Just
to know, maybe you want to load from a json exported by other parser or auto
generated by a server where you don't have libgdx as the json exporter. Even
though, I know it is useful at loading time to determine the class of the map.
Original comment by ariel.co...@gmail.com
on 23 Oct 2012 at 11:58
Well, it seems using setTypeName(null); you avoid exporting the data, so in the
end you could reach the normal behavior, still don't like it is not default
behavior but closing the issue as invalid.
Original comment by ariel.co...@gmail.com
on 25 Oct 2012 at 3:12
Hello guys,
May I ask how do I force the parser to ALWAYS use double quote on keys? We have a server that accepts the following format:
{"key":"mystring", "key": 4}
Thank you
~Zek
Original comment by ezekielb...@gmail.com
on 8 Oct 2013 at 5:11
Original issue reported on code.google.com by
ariel.co...@gmail.com
on 22 Oct 2012 at 1:46