Skip to content
Advertisement

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.createObjectBuilder(). Symptom is

Unwanted quotes in substituted freemarker template fields

I’m generating contents out of a Freemarker template but I get quoted values in my substituted fields. For JSON object In template: I get While I want The Object I feed it with is a JsonNode-tree obtained by Mapping my object with Jackson annotations: Processor: I have the feeling I’m missing some kind of configuration? Answer FreeMarker doesn’t add the

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 when calling the .toString method. Any help

Get Jackson XMLMapper to set root element name in code

How do I get Jackson’s XMLMapper to set the name of the root xml element when serializing? There’s an annotation to do it, if you’re serializing a pojo: @XmlRootElement(name=”blah”). But I’m serializing a generic Java class, LinkedHashMap, so I can’t use an annotation. There’s probably some switch somewhere to set it. Poking around in Jackson code, I see a class

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 located? Main problem concerns an example found here: JSON.simple example

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 json, i.e. the following code should

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 similar question [https://stackoverflow.com/questions/20808901/problems-with-decoding-stack-exchange-api-response] , but I didn’t find any answers for the question. How to decode the api response? Thanks in advance.

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 should

Advertisement