dungnn / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

Provide JsonObject and JsonArray constructors for parsing JSON #439

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I would like to be able to do the following:

JsonObject json = new JsonObject("{a:1,b:2,c:[1,2,3]}");
This will be a handy shortcut to invoke
new JsonParser().parse("{}").getAsJsonObject().

The same could be done for JsonArray.

JsonPrimitive sort of has this support already.

Original issue reported on code.google.com by inder123 on 24 Apr 2012 at 10:44

GoogleCodeExporter commented 9 years ago
I don't think we want to fix this because we would be inconsistent with 
JsonPrimitive.

When you create a JsonPrimitive with the string "[]", we accept that input as a 
string literal. It is _not_ JSON to be parsed! It's best to use JsonParser to 
do JSON parsing.

Original comment by limpbizkit on 30 Jun 2012 at 3:22