pascallouisperez / jsonmarshaller

JsonMarshaller is a Java 1.5 library that allows marshalling and unmarshalling of JSON objects to and from entities ("Java classes").
Apache License 2.0
1 stars 0 forks source link

De-serializing to java fails on toString(2) #16

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Entity:

JSON:

toString()
    [junit] 
{"footer":"footer","header":null,"displayType":"display","imageText":null}

toString(2)
 [junit] ------------- Standard Output ---------------
    [junit] {
    [junit]   "footer": "footer",
    [junit]   "header": {},
    [junit]   "displayType": "display",
    [junit]   "imageText": {},
    [junit] }

What is the expected output? What do you see instead?

First one works
Second one fails with:
    [junit] org.json.JSONObject
    [junit] java.lang.ClassCastException: org.json.JSONObject
    [junit]     at 
com.twolattes.json.StringDescriptor.unmarshall(StringDescriptor.java:30)
    [junit]     at 
com.twolattes.json.StringDescriptor.unmarshall(StringDescriptor.java:12)
    [junit]     at 
com.twolattes.json.ConcreteEntityDescriptor.unmarshallFields(ConcreteEntity
Descriptor.java:273)
    [junit]     at 
com.twolattes.json.ConcreteEntityDescriptor.unmarshall(ConcreteEntityDescri
ptor.java:231)
    [junit]     at 
com.twolattes.json.Marshaller.unmarshall(Marshaller.java:183)
    [junit]     at 
com.twolattes.json.Marshaller.unmarshall(Marshaller.java:172)

Please provide any additional information below.

Original issue reported on code.google.com by nitin.al...@gmail.com on 30 Sep 2008 at 8:07

GoogleCodeExporter commented 9 years ago
Is it intended that org.json.JSONObject.toString() and
org.json.JSONObject.toString(int) do not return the same json structurally?

Before looking at the internals, I was under the impression that they would 
return
the same structure just different white space.

Original comment by jacob.to...@gmail.com on 1 Oct 2008 at 3:25

GoogleCodeExporter commented 9 years ago
We have phased out org.json of the library, this bug is therefore not relevant 
anymore.

Original comment by pascallo...@gmail.com on 14 Dec 2008 at 8:11