Closed GoogleCodeExporter closed 9 years ago
Please can you send me a sample project showing the trouble.
Uriel.
Original comment by uriel.chemouni
on 14 Nov 2011 at 9:52
Sample Android project is attached. Import into Eclipse and run (you will need
Google Android plugin). You will see that the original JSONObject is converted
to plain HashMap during deserialization.
Just to note - this seems to be Android-related problem since the code below
does everything properly
[code]
JSONObject original = (JSONObject)
JSONValue.parse("{one:1,two:[three:3,four:4,five:'five']}");
try {
// serialize
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(out);
oos.writeObject(original);
oos.close();
// deserialize
byte[] pickled = out.toByteArray();
InputStream in = new ByteArrayInputStream(pickled);
ObjectInputStream ois = new ObjectInputStream(in);
Object o = ois.readObject();
System.out.println("Got: " + o + ", with class type of " + (o == null ? null : o.getClass()));
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
[/code]
Original comment by bost...@gmail.com
on 14 Nov 2011 at 8:38
your json message look to be invalide.
"{one:1,two:[three:3,four:4,five:'five']}"
should probably be replaced by:
"{one:1,two:{three:3,four:4,five:'five'}}"
or
"{one:1,two:{three:3,four:4,five:five}}"
or
"{'one':1,'two':{'three':3,'four':4,'five':'five'}}"
Original comment by uriel.chemouni
on 15 Nov 2011 at 10:51
Why? Two is JSON array. It parses just fine, I don't think that is the issue
Original comment by bost...@gmail.com
on 15 Nov 2011 at 11:00
if you want 'two' to be an array use :
"{'one':1,'two':['three',3,'four',4,'five','five']}"
or
"{one:1,two:[three,3,four,4,five,five]}"
Original comment by uriel.chemouni
on 15 Nov 2011 at 11:58
I noticed that you closed this bug - has this been resolved? Can I get a patch?
Original comment by bost...@gmail.com
on 19 Nov 2011 at 9:44
Cross reference to posting on Stackoverflow.com http://goo.gl/CVw1U
Original comment by bost...@gmail.com
on 9 Dec 2011 at 7:39
Original issue reported on code.google.com by
bost...@gmail.com
on 12 Nov 2011 at 7:27