Questions tagged [json-simple]

JSON.simple is a Java-to-JSON binding API that serializes and deserializes JSON data to and from Java data structures.

JSON.simple is a Java-to-JSON binding API designed to be a simple Java toolkit to encode or decode JSON text.

See also:

234 questions
5
votes
3 answers

NoClassDefFoundError when trying to parse JSON with JSON simple

I use JSON simple to parse JSON and I get NoClassDefFoundError when trying to create JSONParser object. import org.json.simple.JSONObject; import org.json.simple.JSONArray; import org.json.simple.parser.JSONParser; ... JSONParser parser = new…
ivknv
  • 305
  • 1
  • 4
  • 14
4
votes
2 answers

Casting JSONArray to Iterable - Kotlin

I am using Json-Simple in Kotlin. In what situations could this cast: val jsonObjectIterable = jsonArray as Iterable Become dangerous? jsonArray is a JSONArray object.
pavlos163
  • 2,730
  • 4
  • 38
  • 82
4
votes
1 answer

jackson vs json simple for stream parsing

I have a json library on github https://github.com/jillesvangurp/jsonj This library has a parser based on json simple, which uses a handler class to do all the work of creating instances of JsonObject,JsonArray, and JsonPrimitive that I have in my…
Jilles van Gurp
  • 7,927
  • 4
  • 38
  • 46
4
votes
4 answers

Simple code for converting JSONObject to a List or JSONArray?

I've read through various threads and found similar problems, but have been pretty unsuccessful at finding a solution for my particular problem. JSONObject orr = (JSONObject)orderRows.get("orderRows"); System.out.println("data in orr = " + orr +…
Mark
  • 2,423
  • 4
  • 24
  • 40
4
votes
1 answer

How to parse from JSON to Map with Json-Simple and retain key order

I'm using Json-Simple to write a config file using JSon-Simple lib, but I'm having problems converting the json string to map. Debugging I have found that parse method returns an object that is a Map! but when I try to cast directly to a LinkedMap I…
Rafael Carrillo
  • 2,772
  • 9
  • 43
  • 64
3
votes
1 answer

XML-JSON Converter Rules

I'm using net.sf.json.xml.XMLSerializer to convert XML documents to JSON. I'm getting two different results for almost two similar XML documents. My code is: public static void main(String[] args) throws DocumentException { String…
Klaus
  • 2,328
  • 5
  • 41
  • 62
3
votes
1 answer

Using Java to decode JSON array of objects

I have JSON as follows: [{"0":"1","id":"1","1":"abc","name":"abc"},{"0":"2","id":"2","1":"xyz","name":"xyz"}] It is an array of objects. I need to parse it using Java. I am using the library at…
Jake
  • 16,329
  • 50
  • 126
  • 202
3
votes
3 answers

Json String can't decode using json-simple toolkit java

JSON-Simple JSON-Simple Example String login = "{\"result\":[104192,42068],\"id\":1}"; Object obj = JSONValue.parse(login); JSONArray array = (JSONArray)obj; This throw a exception Exception in thread "main" java.lang.ClassCastException: …
chrithccmc
  • 1,069
  • 4
  • 14
  • 17
3
votes
1 answer

Java 8 JSON-simple - How can i read a subitem?

I have a Problem in Java, specially in work with the JSON-simple Library. I have found here a code, they does work in the level of a parent node from a json-file but at my case, i read a json-file with childs under the parents. Link to the code: How…
6H057845H
  • 55
  • 2
  • 7
3
votes
1 answer

How to map/deserialize a JSON array to a POJO or POJO List?

I know this question or similar ones have been asked multiple times here, but I swear I've read tons of related posts and none of the solutions seems to be working for me. I'm trying to map some JSON data, which I receive from a specific REST API,…
Sizigia
  • 582
  • 5
  • 10
3
votes
3 answers

How to parse a JSON File without root element using org.json.simple?

I want to parse json file "c:/employeesRecord.json" using org.json.simple library. Below is sample json data, each record is sperated by next line in the file. {"Employees ":["A ;B ;C ;D ;E ;F"],"JobTitle":"Software Engineer"} {"Employees ":["A ;B…
Bahadar Ali
  • 173
  • 1
  • 3
  • 14
3
votes
1 answer

How to parse json request in java spark

I am trying to parse JSON object that is sent using HTTP post "body" request in java-spark. For example if I send JSON object like : {\"name"\ : \"john\", \"age\":\"300\"} . I want to get the name and age in different strings. I have tried this…
MuhammadNe
  • 674
  • 4
  • 11
  • 24
3
votes
3 answers

Parsing a JSON file in Java using json-simple

I have created a .json file: { "numbers": [ { "natural": "10", "integer": "-1", "real": "3.14159265", "complex": { "real": 10, "imaginary": 2 }, "EOF": "yes" } ] } and I want to parse…
George
  • 194
  • 2
  • 5
  • 13
3
votes
0 answers

Removing double quotes from JSON.Simple JSON parser/writer for keys

I would like to remove double-quotes from keys of JSONObjects (JSON.Simple) when converting the object to a String. For example, I have the following JSONObject: JSONObject object = new JSONObject(); object.put("foo",…
Momo
  • 3,542
  • 4
  • 21
  • 34
3
votes
4 answers

JSON Parameter for Web Service

I am trying to create a web service which will taken in JSON response and then query the DB with it to return store details (JSON response). I intend to use this with a mobile app later on. But during the development I am testing using AJAX calls. I…
Ajay Kelkar
  • 144
  • 1
  • 5
  • 20
1
2
3
15 16