Skip to content

Tag: json

java.lang.NoClassDefFoundError: javax/json/Json

I have a simple Java project where I would like to build a Json string. For this, I use javax.json: The project is build with maven, and in the pom I have added these dependencies: Compilation is ok. When I execute the code using that command: The main is in MyClass. I get: on the call to Json.createObjectBui…

JSON object from java ObjectName.toString

I have a java object witch generates this output when i type objectName.toString() : Is there a JSON parser that lets me make a JSON from the string that my object generates? something like: JsonObject x = new JsonObject(busObject.toString()) It is important for me to generate it from the string that i get wh…

Simple json to xml conversion

can anyone share code to convert json to xml this is the json that comes through the request I need json to xml as well as vice- versa .Can any one help me out, I’d prefer code with no jar imports required. Thanks in advance Answer If you are using Java SE and can’t use foreign JARs, and your JSON

Store JSON data in Java

I want to learn JSON data storage in Java using Eclipse, so I googled a lot. I found JSON.simple and GSON. Are those a good choice? I went to Properties >> Java Build Path >> Add External JARs. I added json-simple-1.1.1.jar and google-gson-2.2.4-release.zip. Is it right? Where is the JavaDoc locat…

How do I convert from YAML to JSON in Java?

I just want to convert a string that contains a yaml into another string that contains the corrseponding converted json using Java. For example supose that I have the content of this yaml in a String called yamlDoc: I want some method that can convert the yaml String into another String with the corresponding…

how to decode the Stack Exchange API response

I am trying to retrieve the response of stack exchange api like [http://api.stackexchange.com/2.2/tags?order=desc&sort=popular&site=stackoverflow] I am using the following code to retrieve the response But I am getting the response in decoded form as ���n� �߅f]as��DՊ�I��/�m�(��*Ʃ���Kc��� I found the s…

Write HashMap to JSON in Java

I’m new to Java. I’ve been working on a project that uses Maven and Java 1.7. In my project I have a HashMap. I want to output this HashMap to JSON. What is the recommended approach at this time? When I do a Google search, I get a lot of options (ie Jackson). However, I’m not sure what I sho…