muhsincan / json-simple Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/json-simple
Automatically exported from code.google.com/p/json-simple
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
Hallo I try example 6.1 but i get: [User@a4edc4,User@1f5eb7f,User@381a53]
where is the problem ?
Original issue reported on code.google.com by [email protected]
on 22 Apr 2009 at 8:41
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
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:
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
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
Attachments:
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
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:
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
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
In toJSONString:
{{{
...
if(value instanceof String)
...
}}}
maybe use CharSequence:
{{{
...
if(value instanceof CharSequence)
...
}}}
Reason: GString( groovy strings), StringBuilder converted as toString()
without ""
Original issue reported on code.google.com by [email protected]
on 15 Nov 2009 at 2:15
Attachments:
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
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
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
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
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
It would be better to propagate IOExceptions or ParseExceptions thrown from
JSONParser.parser() and allow developers to handle the error, rather than
test for null and guess as to the actual cause.
Original issue reported on code.google.com by [email protected]
on 29 Nov 2009 at 7:22
Attachments:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.