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
2
votes
1 answer

Xml to JSON Single Valued Array handling

I converted my XML to Json successfully using the below code. I ran into this issue, i have two different XML strings in the below program. First one has single value for user name and the second one has two values. first xml produces the json…
RAJESH
  • 404
  • 6
  • 18
2
votes
5 answers

How to Convert JSON String arrray to Json Array list

I have Json String array ,which looks like this , { {name:"214",value:true,Id:0}, {name:"215",value:true,Id:0}, {name:"216",value:true,Id:0} } and want to covert this string to Json array object and iterate the list to read each object's value.…
ULLAS K
  • 881
  • 2
  • 11
  • 24
2
votes
1 answer

JSON Serializer Android

I am using JSONLib 2.4 for the JSONSerializer() method. Every time I start the activity it force closes. I tried throwing a JSONException, but it gave me an error. What's wrong? This is the call: JSONObject json = (JSONObject)…
Zac Canoy
  • 102
  • 12
1
vote
1 answer

Difference between .put() and .element() methods in JSON?

I am trying to create json object for my data. i found that, i can do that using two methods :- put() and element() please suggest me, which should be used. my data is for example :- key="id" value=32 Thanks in advance !!
mayur
  • 47
  • 1
  • 3
  • 11
1
vote
2 answers

Create a specific JSON String with Gson

When I use JSON-Lib project, I can create with the command JSONObject jObject = new JSONObject(); jObject.accumulate("articles", list); String json = jObject.toString(); The following Output: { "articles": [ { "amount":…
mybecks
  • 2,443
  • 8
  • 31
  • 43
1
vote
2 answers

Does jackson throws the Cyclic exception?

Does jackson Handles/throws the Cyclic exception like net.sf.json.JSONException: There is a cycle in the hierarchy! thrown in json-lib when it detects the cycle in java object that is to be converted in json. If so how can we handle it. Error…
1
vote
1 answer

Parsing dates with json-lib

I have the following JSON object: {"startDate":"30/01/2008","startPeriod":"2008","dboid":"5308204301485575800000","action":"update","grid":"variantAssigGrid","endDate":"30/01/2011","endPeriod":"2011","institution":"5301004301485575300000"} After…
Lluis Martinez
  • 1,963
  • 8
  • 28
  • 42
1
vote
2 answers

Basic JSON-lib example

I'm trying to use JSON-lib, but I can't get it to run without NoClassDefFoundError. Here's the code: import net.sf.json.*; public class hello { public static void main(String[] args) { String settings = "{\"hello\": \"world\"}"; …
beatgammit
  • 19,817
  • 19
  • 86
  • 129
1
vote
1 answer

json object in JSP

I imported net.sf.json package to use the feature of JSON in my jsp apge but as soon as I create an object of JSONArray it throws me NoClassDefinitionFound. //line 50 JSONObject responcedata=new JSONObject(); exception thrown…
Rahul
  • 119
  • 2
  • 12
1
vote
1 answer

How to exclude properties from bean to json at runtime

I want to exclude properties from bean to json using json-lib at runtime. How can i do it? I have tried using propertyFilter of jsonconfig, I am not sure if its at runtime.
sarah
  • 77
  • 2
  • 9
1
vote
3 answers

Invalid character while converting from JSON to XML using jsonlib

I'm trying to convert a JSON string to XML using jsonlib in Java. JSONObject json = JSONObject.fromObject(jsonString); XMLSerializer serializer = new XMLSerializer(); String xml = serializer.write( json ); …
Jophin Joseph
  • 2,864
  • 4
  • 27
  • 40
1
vote
1 answer

What could cause a program to be blocked on a monitor it appears to own?

I recently had a problem with three separate servers running the same code all experiencing the same symptoms. These are high volume REST / JSON servers that use json-lib to create the JSON responses. The servers all eventually hang with most of the…
1
vote
4 answers

Convert JSON String to Java object for easy use in JSP

Is their an easy way or library to convert a JSON String to a Java object such that I can easily reference the elements in a JSP page? I think Map's can be referenced with simple dot notation in JSP pages, so JSON -> Map object should work? UPDATE:…
at.
  • 50,922
  • 104
  • 292
  • 461
1
vote
1 answer

json String transform to Java Bean

When I run the code, it reports: Exception in thread "main" java.lang.ClassCastException: net.sf.json.JSONObject cannot be cast to ColorData at..... The Code is: public class JsonTest { public static void main(String[] args) { …
L. YanJun
  • 277
  • 3
  • 15
1
vote
0 answers

read simple json lib file

Today I started learning about json files and I made a test using NetBeans and json-lib : package tp; import java.io.FileInputStream; import java.io.IOException; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import…
Ionut
  • 1,729
  • 4
  • 23
  • 50