Questions tagged [json-lib]

JSON-lib is a Java-to-JSON binding API that serializes and deserializes JSON data to and from Java data structures. It also includes some support for translations between XML and JSON.

JSON-lib is a Java-to-JSON binding API, hosted at http://json-lib.sourceforge.net, designed for easy and customizable deserialization and serialization of JSON data to and from Java data structures. It also includes some support for translations between XML and JSON.

Alternatives

Alternative Java-to-JSON binding solutions with similar APIs include Jackson, Google Gson, and svenson. Yet more are listed at json.org.

Pros and cons of the different APIs are discussed in the https://stackoverflow.com/questions/338586/a-better-java-json-library post.

Performance

The latest performance benchmarks for these and other JSON serialization and deserialization solutions are available at https://github.com/eishay/jvm-serializers/wiki.

76 questions
13
votes
1 answer

Convert json string to Java Map(JSONLib)

How can I convert json string to Java Map using JSON-lib(http://json-lib.sourceforge.net/) ? I can convert to DynaBean: JSONObject jsonObject = (JSONObject) JSONSerializer.toJSON( str ); DynaBean bean = (DynaBean) JSONSerializer.toJava( jsonObject…
Le_Coeur
  • 1,521
  • 5
  • 28
  • 44
8
votes
2 answers

How to force JSON-lib's JSONObject.put(..) to escape a string containing JSON?

When using JSON-lib's JSONObject, how can I stop the put method from storing a String which contains JSON as JSON rather than as an escaped string? For instance: JSONObject obj = new…
Ben Burns
  • 14,978
  • 4
  • 35
  • 56
6
votes
2 answers

JSON-lib escaping / preserving strings

I am using JSON-lib library for java http://json-lib.sourceforge.net I just want to add simple string which can look like JSON (but i do not want library to automatically figure out that it might be json and just to treat it as string). Looking into…
Mike Pandorium
  • 143
  • 2
  • 5
5
votes
2 answers

Processing shell-style comments in JSON

I'm dealing with systems which manipulate "relaxed" JSON data which includes shell-style # line comments: [ { # Batman "first-name": "Bruce", "last-name": "Wayne" }, { # Superman "first-name": "Clark", "last-name":…
Richard JP Le Guen
  • 28,364
  • 7
  • 89
  • 119
4
votes
5 answers

parsing json with java

I am a newbie to json parsing, I have grabbed a json string from a request and now I need to parse it with java. I'm using json-lib for this. But I'm really stuck as I'm not familiar with it. I need to extract following data 1. name (hotel name) 2.…
Pavithra Gunasekara
  • 3,902
  • 8
  • 36
  • 46
4
votes
0 answers

Apache Camel: XMLJSON conversion for empty tags to strings instead of arrays

When using the Camel XMLJSON library and when converting an XML message to JSON using the unmarshal option. The application is converting the empty tags to empty JSON arrays. Is there a way to override this behavior to instead convert it into empty…
3
votes
2 answers

NoSuchMethodError with JSON-Lib and JDK 1.4

I've downloaded the supposedly latest JDK 1.3 compatible binary named json-lib-2.4-jdk13.jar and am getting the following error. Exception in thread "main" java.lang.NoSuchMethodError: java.lang.ThreadLocal: method remove()V not found at…
Brad
  • 15,186
  • 11
  • 60
  • 74
3
votes
4 answers

Can't parse JSON property "null"

I faced with one trouble when tried to parse JSON "null" property, please help me to understand what's the real problem. I had a following JSON: { "properties" : { "null" : { "value" : false } } } I used…
erkfel
  • 1,588
  • 2
  • 17
  • 29
3
votes
1 answer

How to copy all the values from one JSONObject to another?

I understand that it's perfectly possible to copy each individual component over one by one, but it's extremely messy to do and rather ugly. Isn't there a simpler way to copy all the values from one JSONObject to another? Important to note, I am…
davidalayachew
  • 1,279
  • 1
  • 11
  • 22
3
votes
0 answers

How json treats if there is a forward slashes in json string

I Have a json string as below: [ { "NAME" : "KANTESH", "SNAME" : "NAGARADDER", "MSG1" : "\"HELLO:HOW ARE YOU\"\n", "MSG2" : "\"HELLO:///HOW ARE YOU\"\n", "ID" : 20074499 } ] when i am trying to remove the white spaces…
K.H.Nagaradder
  • 71
  • 1
  • 1
  • 5
3
votes
1 answer

Why can "class", "metaClass" and "declaringClass" not be used as keys in JSON-lib?

I stumbled about the effect, that the default configuration of JSON-lib (2.4) does not allow to use values with the keys class, metaClass and declaringClass (see JsonConfig.DEFAULT_EXCLUDES). Such key-value pairs are stripped from the JSON…
Nico
  • 1,554
  • 1
  • 23
  • 35
3
votes
1 answer

How to format array elements during json to xml convertion using json-lib?

The below json converted to xml using json-lib utility. {    "tms:getTaskListResponse": {       "tms:task": [          {             "tms:creationDate": "2013-05-06T12:02:21.530+05:30",             "tms:instanceId":…
cyrilantony
  • 274
  • 3
  • 14
3
votes
1 answer

How to add class name when serialize to json by net.sf.json

I am planning to provide a interface to iOS Apps, the developer asked to add an additional field call class contains the name of the pojo I used on server so he can convert to his class on client easily. The problem is I have to do this when the…
Shisoft
  • 4,197
  • 7
  • 44
  • 61
3
votes
1 answer

JSONObject.put() won't store a reference of another JSONObject

have you noticed that if you put a JSONObject into another JSONObject with put(), the container JSONObject won't store the reference to the first JSONObject, but a new JSONObject? An example: JSONObject jtmp1 = new JSONObject(); JSONObject jtmp2 =…
kRs
  • 140
  • 7
2
votes
3 answers

How do I put more than one JSON instance in a single JSON object using net.sf.json.JSONObject library

//create the JSON Object to pass to the client JSONObject object=new JSONObject(); //one instance object.put("name","something2"); object.put("status", "up"); //second instance object.put("name", "something2"); object.put("status",…
stackoverflow
  • 18,348
  • 50
  • 129
  • 196
1
2 3 4 5 6