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…
Tag: json
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…
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…
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…
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…
Error parsing data org.json.JSONException: End of input at character 0 of – Android
I’m developing a test Android application that must display some data from a mysql db. Here my logs: Here the class JSONParser.java Here the class I use to display the selected data: Here the php file: In addition, here the main Activity: I read various thread around the internet about this error, but i…
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…