Giter Site home page Giter Site logo

Comments (7)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 20, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 20, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 20, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 20, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 20, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 20, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 20, 2024
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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.