Comments (7)
Please can you send me a sample project showing the trouble.
Uriel.
Original comment by uriel.chemouni
on 14 Nov 2011 at 9:52
from json-smart.
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 [email protected]
on 14 Nov 2011 at 8:38
from json-smart.
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
from json-smart.
Why? Two is JSON array. It parses just fine, I don't think that is the issue
Original comment by [email protected]
on 15 Nov 2011 at 11:00
from json-smart.
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
- Changed state: Done
- Added labels: Type-Review
- Removed labels: Type-Defect
from json-smart.
I noticed that you closed this bug - has this been resolved? Can I get a patch?
Original comment by [email protected]
on 19 Nov 2011 at 9:44
from json-smart.
Cross reference to posting on Stackoverflow.com http://goo.gl/CVw1U
Original comment by [email protected]
on 9 Dec 2011 at 7:39
from json-smart.
Related Issues (20)
- net.minidev.json.parser.ParseException should NOToverride toString() but getMessage() HOT 4
- Replace all usages of StringBuffer with StringBuilder HOT 1
- Support for reading ASCII hexidecimal excape sequences HOT 2
- Clones of json-smart are empty HOT 2
- Issue with json validation/parse and quotes HOT 4
- ParseException contains misspelling ("secance") HOT 2
- java.lang.SecurityException: Prohibited package name: java.lang HOT 3
- JSONValue.parse returns float instead of string with MAX_COMPRESSION HOT 4
- Is the project dead ? HOT 3
- JSONParser of json-smart is not throwing exception for invalid json string HOT 4
- Invalid JSON is getting parsed instead of throwing exception HOT 2
- JSONValue.parse does not correctly decode UTF-8 bytes from an inputstream HOT 2
- BigDecimal serialization is not supported HOT 6
- json-smart JAR does not export the writer package for OSGi HOT 3
- Multiple dex files define Lorg/objectweb/asm/AnnotationVisitor; HOT 4
- json-smart should not package the asm classes HOT 6
- No Getter for field scale in class java.math.BigDecimal HOT 4
- IllegalAccessError when trying to serialize java.util.Calendar HOT 1
- RuntimeException in JSONAware.toJSONString() HOT 1
- In Java 8, creating classes in java.lang is forbidden.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from json-smart.