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

Unable to compile JSONObject in JSP

please assist me anyway you can with the following code(using Intellij IDEA 14.0 demo , but I fire up Tomcat manually,using TOMCAT8.exe): <%@ page language="java" %> <%@ page import="org.apache.commons.lang3.*" %> <%@ page…
user1311432
  • 64
  • 1
  • 7
0
votes
1 answer

Need to converting POJO to JSON using net.sf.json JsonSerializer with maintaining the POJO attribute ordering

I'm using net.sf.json API for all JSON operations. I'm trying to convert a POJO to JSON using JSONSerializer.toJSON(POJO, JsonConfig). I would like the resulting JSON to have the POJO attributes in the same order as specified in the POJO. But what…
Gnana
  • 614
  • 1
  • 7
  • 18
0
votes
1 answer

Why JSON object printed as String in JSP?

In my Servlet a JSONObject is created with the value: {'alerts':true} When I am trying to print its value on JSP page using , it is printing the JSON object as String . It is printed as "{'alerts':true}" How do I print in JSON format rather than…
0
votes
1 answer

Error with the json-lib library for java

I have a problem with the json-lib library for java, it turns out that if the JSON that I get only one record I have not added the [], but if you have more than one record if I add them. This is my code that comes from a SQL query: while…
0
votes
1 answer

Caused by: java.lang.ClassNotFoundException: net.sf.json.xml.XMLSerializer not found by com.myproject.core [35154]

I use json-lib to convert xml structure to json format. My dependencies looks like this: net.sf.json-lib json-lib
Max_Salah
  • 2,407
  • 11
  • 39
  • 68
0
votes
0 answers

Deserialize string value by JSON-lib (net.sf.json)

I have discovered problem in JSON-Lib with deserialization of JSON string data in nested objects. Following code in Groovy demonstrates problem, you can test it in Groovy Console: @Grab('net.sf.json-lib:json-lib:2.3:jdk15') import net.sf.json.* def…
mschayna
  • 1,300
  • 2
  • 16
  • 32
0
votes
2 answers

how can I make the json format like that use json-lib?

I print the json string use this code: fatherList.put("totalPage",il.size()); il=item.loadList(si,ps," a.cat_id ="+itemCat," a.id "); List itemsList=new ArrayList(); for(int i=0;i
chanjianyi
  • 607
  • 4
  • 15
  • 35
0
votes
1 answer

A Not-Null String with literal value 'null' not handled correctly - BUG in JSON-lib

Came across a recent issue where user submitted string value 'null' is being stored into the data base as '"null"'. Basically double quotes are being added at the start and end of the String. Investigation revealed that JSON-lib doesn't seem to…
0
votes
1 answer

Java JSON-Lib Set Field only one entry

I am having a correct JSON String which is made out of an Object A, containing a Set of other Objects B. When I try to get back this Object now from the JSON String, the Set of Objects B will only have a single entry, instead of all the contained in…
Benny
  • 1,435
  • 1
  • 15
  • 33
0
votes
1 answer

With Jackson is it possible to just ignore all cyclic relationship without having to add annotation?

Jackson 2.0 has pretty good support for cyclic reference, however, it seems that all require to annotate the POJO classes. What if I cannot edit the java classes I want to serialize to json, but want to just ignore cyclic reference like the json lib…
Jeremy Chone
  • 3,079
  • 1
  • 27
  • 28
0
votes
2 answers

Escape for net.sf.json.JSONObject

When I have to give a JSONObject.fromObject this popping an exception here 'true' = 'true' pq are the single quote inside another single quote, someone knows some kind of escape character for this API? public static void main(String[] args) { …
Michel Miola
  • 3
  • 2
  • 5
0
votes
2 answers

json-lib - how many classes does JSONSerializer require?

I'm trying to parse some JSON data, and I'm using the examples from this site: http://answers.oreilly.com/topic/257-how-to-parse-json-in-java I'm using the data from section 2 and the code from section 3, and json-lib as my JSON library. But when I…
Danny
  • 705
  • 1
  • 7
  • 23
0
votes
1 answer

JSON.h file not found in iPhone?

Possible Duplicate: JSON.h : File not found when trying to import the JSON framework Currently i am working in iphone application, Using JSON Parser to parse Local JSON files, so i have import JSON library in my project, then i tried to import…
SampathKumar
  • 2,525
  • 8
  • 47
  • 82
-1
votes
2 answers

Grails Run-app exception "ClassNotFoundException: net.sf.json.JSONObject"

I am getting the above exception when i do run-app on my grails application [java.lang.ClassNotFoundException: net.sf.json.JSONObject , at org.codehaus.groovy.tools.RootLoader.findClass(RootLoader.java:156) , at…
BrownTownCoder
  • 1,312
  • 5
  • 19
  • 25
-1
votes
2 answers

How to populate JSON from Hashmap data?

I'm working with this data in Java: HashMap currentValues = new HashMap(); String currentID; Timestamp currentTime; String key; I need to convert this to JSON, but I can't work out how. Currently I think this is the…
user3420034