GithubHelp home page GithubHelp logo

json-simple's People

json-simple's Issues

forward slashes are unnecessarily escaped

System.out.println(JSONValue.toJSONString("a/b/c"));

yields

"a\/b\/c"

-------

So here's the deal. After asking this question
http://stackoverflow.com/questions/1580647, it looks like the JSON spec
allows but does not require forward slashes to be escaped. (see RFC4627
http://www.ietf.org/rfc/rfc4627.txt p.4) 

So technically this issue is not a bug... but it makes file paths look
really ugly.

Apparently the string "</" is problematic in a few circumstances (namely
inside <script> tags in HTML).

Is there any way you could change the behavior of json-simple so either
it's user-selectable whether forward slashes in strings are escaped, or you
only escape "</" to "<\/"? 


Original issue reported on code.google.com by [email protected] on 16 Oct 2009 at 10:23

org.json.simple.parser.ParseException should override get[Localized]Message

What steps will reproduce the problem?
1. capture a org.json.simple.parser.ParseException
2. use the 'getMessage' or 'getLocalizedMessage' API
3. returns NULL (when there is a message returned by toString)

What is the expected output? What do you see instead?
Should be the same as the 'toString()' method; or at least comparable useful.

What version of the product are you using? On what operating system?
1.1

Please provide any additional information below.
Right now the ParseException's 'toString' method is overridden. Which
leaves the get[Localized]Message APIs doing nothing. The override should
be in the get[Localized]Message and the inherited toString will work
fine. This will cover all three methods...

Original issue reported on code.google.com by [email protected] on 9 May 2009 at 10:50

Parser doesn't raise exception on space delimited values in JSON arrays and objects

What steps will reproduce the problem?
1. Define two strings "[1 2 3]" and "{\"key1\" \"val1\" \"key2\" \"val2\"}"
2. Pass the strings to org.json.simple.parser.JSONParser.parse()
3. No ParseException will be raised, the parser returns a valid JSONArray /
JSONObject.

What is the expected output? What do you see instead?
JSON arrays and objects have their values/key-value pairs separated by
commas. The parser, however, seems also to accept tokens that are separated
by space only. The same happens to the ":" operator for object key-value pairs.

What version of the product are you using? On what operating system?
JSON.simple 1.1 / Java 1.6 / Linux

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 5 Jan 2010 at 1:35

Attachments:

java.lang.ClassCastException: org.json.simple.JSONObject cannot be cast to org.json.simple.JSONArray

Hi there
I'm new to json-simple, tried to use it to decode a json string that
encoded by PHP(it was 2-dimension array in PHP) json_encode, the string
looks like

 {"User_001":{"first_name":"xxx","last_name":"xxx","name":"xxx
xxx","uid":"1571575199","pic_square":"http://profile.ak.fbcdn.net/v230/639/72/q5
71575199_2451.jpg","profile_url":"http://www.facebook.com/profile.php?id=5715751
99"}}

but it reports error at run time:

java.lang.ClassCastException: org.json.simple.JSONObject cannot be cast to
org.json.simple.JSONArray


any idea why? thanks for any help.

Original issue reported on code.google.com by [email protected] on 6 Nov 2009 at 10:54

Support serialization of arrays

What steps will reproduce the problem?
1. It'd be nice if JSONValue.writeJSONString() and JSONValue.toJSONString() 
handled arrays.  Right 
now it'll serialize Lists, but an array is serialized by calling toString() on 
the array.

What version of the product are you using? On what operating system?
Using the latest version 1.1

Please provide any additional information below.
I've attached a patch that works with arrays.

Original issue reported on code.google.com by [email protected] on 4 Dec 2009 at 7:26

  • Merged into: #7

Attachments:

putting a Date into a JSONObject

What steps will reproduce the problem?
1. putting a Date-object into a JSONObject

What is the expected output? What do you see instead?
I expected a String representation of that Date, but I get it without
quotes, so the JSON is not valid.


What version of the product are you using? On what operating system?
version 1.1 of json-simple


To fix it, I have to "convert" the date by toString().

Original issue reported on code.google.com by [email protected] on 20 Apr 2009 at 1:33

OSGified json-simple.jar

In order to play nicely in an OSGi environment, some simple entries in the 
MANIFEST.MF must be 
provided. I attachted a patch against build.xml (1.1) which use the bnd tool to 
generate that 
manifest (you need to download bnd.jar from http://www.aqute.biz/Code/Download 
and put it into 
a new "tools/" directory).

Alternatively, the generated MANIFEST.MF could be checked in and used directly 
with the jar target 
(which I would recommend to its simplicity). I added an example to this ticket.

It would be nice, if in some coming version the OSGi Headers would be present 
so that this fine 
library could be used as an OSGi Bundle as well.

thx ...
...roland.

Original issue reported on code.google.com by [email protected] on 14 Feb 2010 at 10:48

Attachments:

failure to handle commants in JSON...

What steps will reproduce the problem?
1. create String s = "/* a comment */ { "name":"value" }
2. try using this string in the parser.
3. watch the parser fail.

What is the expected output? What do you see instead?
{ "name":"value" }

What version of the product are you using? On what operating system?
Windows OS

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 9 Sep 2009 at 6:21

Encoder escapes forward slashes

Minor issue: JSON encoder adds a backslash before every "/" in the string.
While JSON spec *allows* to escape "/", it's not required, and escaping it
reduces readability of the encoded data, and unnecessarily increases the
size of the encoded string.

Could you consider not escaping the forward slash?

Original issue reported on code.google.com by [email protected] on 3 Nov 2009 at 12:24

  • Merged into: #8

Raw types when inheriting from HashMap, instead of <Object,Object>

This implementation choice makes it impossible to use json-simple with Scala 
without modification. However, everything works fine when updating the 
JSONObject declaration to the following:

public class JSONObject extends HashMap<Object, Object> implements 
Map<Object, Object>, JSONAware, JSONStreamAware{

This is also probably a Scala bug, but people seemed to think it is a better 
practice to use typed HashMap instead of raw.

See <http://old.nabble.com/Complicated-type-error-with-
org.json.simple.JSONObject:put-td26716918.html> for full details.

Cheers,

 -- Sébastien

Original issue reported on code.google.com by [email protected] on 15 Dec 2009 at 1:20

Issue when parsing

Hi when I run the following
        jsonData = NetUtils.getHTTPFile("http://www.iobridge.com/api/feed/key=" + feedKey);
        JSONParser parser = new JSONParser();
        Object obj = null;
            //parse the JSON data
        try {
               obj = parser.parse(jsonData);
        } catch (ParseException e) {}
              JSONArray array=(JSONArray)obj;
              System.out.println(array.get(1));
              JSONObject obj2=(JSONObject)array.get(1);
              System.out.println(obj2.get("1"));

I get the following Exception
Exception in thread "main" java.lang.ClassCastException: 
org.json.simple.JSONObject
        at IOB.IOBModule.<init>(IOBModule.java:33)
        at myroomcontrol.Main.main(Main.java:30)
Java Result: 1

Original issue reported on code.google.com by [email protected] on 17 Feb 2009 at 9:31

Object[] not serializable

What steps will reproduce the problem?

Create a Object[] and then try to transform to a JSON string.
In example: org.json.simple.JSONValue.toJSONString(new Object[] {"1"})


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

The output should be like the java.util.List's output. I.e.: ["1"]
The call returns a "toString()" output. I.e.: [Ljava.lang.Object;@2ad191


What version of the product are you using? On what operating system?

json_simple-1.1.jar


Please provide any additional information below.


Original issue reported on code.google.com by atec.post on 19 Feb 2009 at 12:51

Suggestion about JSONValue.toJSONString

Hello, It would be useful to include 

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

I hope you can include this two simple lines

Thanks a lot

Original issue reported on code.google.com by [email protected] on 6 Oct 2009 at 6:01

Excessive memory consumption in parse()

Summary:
I'm using JSON Simple in our Android application. I recently noticed I was
getting occasional OutOfMemory errors, and it turned out that
JSONParser.parse() is the problem. Parsing this simple JSON document
(http://api.qype.com/v1/places/27539/reviews.json?page=1 -- you need a
consumer key to actually see that) will cause a memory consumption of over
10 MB.

What steps will reproduce the problem?
I'm not sure whether this happens outside the Android environment. But what
I did is this:

    private JSONObject parseJsonReply(InputStream data) throws ParseException,
            ConnectionFailedException {

        if (modelName == null || modelListName == null) {
            String className = getClass().getSimpleName();
            int idx = className.indexOf("Parser");
            modelName = className.substring(0, idx).toLowerCase();
            modelListName = modelName + "s";
        }

        BufferedReader reader = new BufferedReader(new
InputStreamReader(data));
        StringBuilder sb = new StringBuilder();

        try {
            String line = reader.readLine();
            while (line != null) {
                sb.append(line);
                line = reader.readLine();
            }
        } catch (IOException e) {
            throw new ConnectionFailedException(e);
        }

        return (JSONObject) jsonParser.parse(sb.toString());
    }

What version of the product are you using? On what operating system?
json-simple 1.1 on Android 1.5 (HTC Hero)

Original issue reported on code.google.com by [email protected] on 27 Nov 2009 at 11:35

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.