Giter Site home page Giter Site logo

Comments (6)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
Got it solved for me. Before calling JSONValue.toJSONString(o) I do this:

        if (o instanceof Object[])
            o=java.util.Arrays.asList((Object[])o);

and it works as expected for arrays of Strings. Still it would be nice to have 
similar code somewhere inside the library so such arrays inside other objects 
would work automatically.

Original comment by [email protected] on 1 Jul 2010 at 7:52

from json-simple.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
The easy fix seems to be to add this line

                if(value instanceof Object[])
                        return JSONArray.toJSONString((List)java.util.Arrays.asList((Object[])value));

after line here
http://code.google.com/p/json-simple/source/browse/trunk/src/org/json/simple/JSO
NValue.java#149 and even nested java arrays inside lists or maps should work. 

This does not add too much overhead since java.util.Arrays.asList wraps array 
into ArrayList backed up by the very same array (so the array itself is not 
copied).

Original comment by [email protected] on 14 Jul 2010 at 11:54

from json-simple.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
Sorry, in previous comment I meant this line 
http://code.google.com/p/json-simple/source/browse/tags/tag_release_1_1/src/org/
json/simple/JSONValue.java#204

But line 149 should be fixed in similar manner with toJSONString replaced by 
writeJSONString.

Original comment by [email protected] on 14 Jul 2010 at 12:13

from json-simple.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024

Original comment by [email protected] on 14 Jul 2010 at 1:10

  • Changed state: Accepted
  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

from json-simple.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024

Original comment by [email protected] on 14 Jul 2010 at 1:14

  • Changed state: Duplicate

from json-simple.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
Oh, seems like I was reinventing the wheel. Totally missed issue #7 due to its 
generic name. Oh well, at least next person reporting this issue may find it 
easier :-)

Original comment by [email protected] on 14 Jul 2010 at 2:01

from json-simple.

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.