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
288
votes
20 answers

Pretty-Print JSON in Java

I'm using json-simple and I need to pretty-print JSON data (make it more human readable). I haven't been able to find this functionality within that library. How is this commonly achieved?
mabuzer
  • 6,497
  • 6
  • 35
  • 41
141
votes
22 answers

How to read json file into java with simple JSON library

I want to read this JSON file with java using json simple library. My JSON file looks like this: [ { "name":"John", "city":"Berlin", "cars":[ "audi", "bmw" ], …
billz
  • 1,419
  • 3
  • 11
  • 7
57
votes
3 answers

How to find specified name and its value in JSON-string from Java?

Let's assume we have the next JSON string: { "name" : "John", "age" : "20", "address" : "some address", "someobject" : { "field" : "value" } } What is the easiest (but still correct, i.e. regular expressions are not…
Roman
  • 64,384
  • 92
  • 238
  • 332
32
votes
4 answers

Iterate through JSONObject from root in json simple

I am trying to iterate over a json object using json simple. I have seen answers where you can do a getJSONObject("child") from { "child": { "something": "value", "something2": "value" } } But what if I just have…
Z2VvZ3Vp
  • 7,033
  • 6
  • 21
  • 35
30
votes
1 answer

JSON.simple API Javadoc

Is there a Javadoc for JSON.simple?
cp.
  • 1,241
  • 5
  • 15
  • 26
28
votes
5 answers

How can I cast a JSONObject to a custom Java class?

In Java (using json-simple) I have successfully parsed a JSON string which was created in JavaScript using JSON.stringify. It looks like this: {"teq":14567,"ver":1,"rev":1234,"cop":15678} This string is storing the state of a custom JavaScript…
Geek Stocks
  • 2,010
  • 3
  • 27
  • 43
20
votes
4 answers

Decode JSON string in Java with json-simple library

I am new to using the json-simple library in Java and I've been through both the encoding and decoding samples. Duplicating the encoding examples was fine, but I have not been able to get the decoding ones to work with mixed type JSON. One of my…
Sharda Singh
  • 727
  • 3
  • 10
  • 19
17
votes
5 answers

JSON-Simple causes compiler warning "Type safety: The method put(Object, Object) belongs to the raw type HashMap."

I Just came across a situation where I need to put the data in the JSONObject, while doing that I received a warning from the compiler regarding. Type safety: The method put(Object, Object) belongs to the raw type HashMap. References to generic…
vaibhav
  • 762
  • 2
  • 12
  • 34
16
votes
4 answers

Add JSON Package Reference; new to Java

I'm brand new to Java and have always been a c kind-of-guy. That being said, I'm trying to use the JSON libraries (packages? classes? Java terminology is so damn confusing!) and am having issues adding them as a reference. These three imports cannot…
Matt
  • 205
  • 1
  • 3
  • 5
12
votes
2 answers

How to tell if return is JSONObject or JSONArray with JSON-simple (Java)?

I am hitting a service and sometimes getting back something like this: { "param1": "value1", "param2": "value2" } and sometimes getting return like this: [{ "param1": "value1", "param2": "value2" },{ "param1": "value1", "param2": "value2" }] How…
Z2VvZ3Vp
  • 7,033
  • 6
  • 21
  • 35
10
votes
1 answer

Error JSON.simple: java.util.zip.ZipException: duplicate entry: org/hamcrest/BaseDescription.class

I am facing a problem in android studio after adding JSON.simple and enabling MultiDex and get the following error: Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'. java.util.zip.ZipException: duplicate entry:…
9
votes
4 answers

How to ignore case when searching a JSON Object

My sample JSON input is as follows: "JobName":"Test Job 1", "events":[ { "features":[], "InputHiveTable":"uilog_uiclientlogdata", "eventColumn":"command", …
Chaos
  • 11,213
  • 14
  • 42
  • 69
7
votes
3 answers

Gradle dependency json-simple error

I'm fairly new to Gradle so I'm trying to build a Java project and not sure about the dependencies. I have never gotten Gradle configured to be able to do my tests or now a jar file to compile and run. My build.gradle: apply plugin: 'java' apply…
April_Nara
  • 1,024
  • 2
  • 15
  • 39
5
votes
3 answers

Parsing a JSON from HTTP Response in Java

Hi I am using Client Http (apache), and json-simple. I want to access the attributes of the json response, and then use them. Any idea how to do this? I read a post and did not work as it but me. This is my answer…
jojemapa
  • 873
  • 2
  • 10
  • 21
5
votes
1 answer

unchecked call to add(E) as a member of the raw type ArrayList and HashMap

I have the following function that uses org.json.simple to create JSON object. public JSONObject createJSONRequest() { // /* Create JSON Objects */ JSONObject jsonObject = new JSONObject(); Map map = new HashMap
ant2009
  • 27,094
  • 154
  • 411
  • 609
1
2 3
15 16