jettison

Simple JSON value parsing for Java 8

人盡茶涼 提交于 2020-01-14 04:00:07
问题 Java 8 here though I have Jackson and Jettison on my classpath already (as dependencies). I am being given the following string of JSON (as an example): { "widgets": { "email": "someone@example.com", "maxSize": 50 }, "environments": { "LOCAL": { "maxSize": "40" }, "DEV": { "maxSize": "100" } }, "fruits": [ "apples", "oranges" ] } At runtime the values of the fields will be different. I am just trying to read the value of environments/DEV/maxSize from this string; what is the simplest code I

Simple JSON value parsing for Java 8

微笑、不失礼 提交于 2020-01-14 04:00:06
问题 Java 8 here though I have Jackson and Jettison on my classpath already (as dependencies). I am being given the following string of JSON (as an example): { "widgets": { "email": "someone@example.com", "maxSize": 50 }, "environments": { "LOCAL": { "maxSize": "40" }, "DEV": { "maxSize": "100" } }, "fruits": [ "apples", "oranges" ] } At runtime the values of the fields will be different. I am just trying to read the value of environments/DEV/maxSize from this string; what is the simplest code I

json xml converter having array in json string

早过忘川 提交于 2020-01-11 11:29:07
问题 I need to convert a json to xml and later on converting that json back to xml, but i am loosing the json array object while this conversion - I am using org.json lib. Json String - { "readResult": { "errors": [{ "code": 400 }] } } Codebase - using org.json lib String xml = XML.toString(new JSONObject("inputjsonstring")); String json = XML.toJSONObject(xml).toString(); Output xml and json - XML - <readResult><errors><code>400</code></errors></readResult> JSON - { "readResult": { "errors": {

Axis2 JSon Support (Jettison) bad xml conversion

南笙酒味 提交于 2019-12-25 02:46:35
问题 I am using Axis2 1.6.4 to implement REST Json WebServices (https://axis.apache.org/axis2/java/core/docs/json_support.html) and I face an issue when Jettison converts Json object To XML if it does not have a "root" element. Details: If request is: {"name":"John","age":30} Then XML OMElement at server side is: <name>John</name So age element is missed Instead, if request is: {person:{"name":"John","age":30}} Then XML OMElement at server side is: <person><name>John</name><age>30</age></person>

Using jaxb to represent a list as the root element

▼魔方 西西 提交于 2019-12-23 16:13:58
问题 How can we marshal/unmarshal the root element in a JSON that contains a list using JAXB? So it would the JSON as { "tag" : [ { "id" : "a", "id2": "aa" }, { "id" : "b", "id2" : "bb" }, { "id" : "c", "id2" : "cc" } ] } I am using Apache CXF which supports JSON through Jettison. The Java class could look like the one below. One could use a XmlList annotation for the list, and XmlValue for having that list in the root element. The problem is XmlValue would not take a user-defined type.

XML wrapped list to JSON array via Jettison and JAXB

可紊 提交于 2019-12-21 12:33:14
问题 I'm using JAXB to marshal an annotated object to XML in the form: <channels> <channel>Test A</channel> <channel>Test B</channel> </channels> I want to marshal this to JSON instead using JAXB (ala http://blog.bdoughan.com/2011/04/jaxb-and-json-via-jettison.html) but it marshals to something like the following: "channels" : { "channel" : [ "Test A", "Test B" ] }, Really I want it to marshal into the following form: "channels" : { {"Test A"}, {"Test B"} }, How can I do this? Is it the right

Spring Batch, JdbcExecutionContextDao java.util.Map$Entry deserializer issue, xstream 1.4.1

别说谁变了你拦得住时间么 提交于 2019-12-21 05:09:21
问题 I have a problem using Spring Batch 2.1.9: when i use jobExplorer.getJobExecution(jobExecutionId) , i find a problem when DAO has to deserialize a string like: {"map":[{"entry":{"string":"parsedComparingDate","date":"2014-03-08 23:00:00.0 UTC"}}]} from the BATCH_JOB_EXECUTION_CONTEXT table, using method JdbcJobExecutionDao.getJobExecution() . I know that spring batch uses xstream 1.3, but in my Pom, i have: spring-batch 2.1.9 ; xstream 1.4.1 (inherited from smooks); jettison 1.3.3 (inherited

Java Jersey Jettison Message Body Reader Exception

安稳与你 提交于 2019-12-18 06:54:10
问题 I am a complete beginner at REST services but I need to access some information via REST from a web site. The service has some sample code to show how to login that I have used. The sample code uses Jettison as a JSON parser but when I try to run the following code snippet I get an Exception: JSONObject post = baseResource.path("login") .queryParam("service", "ABC").queryParam("auth", authParam) .accept(MediaType.APPLICATION_JSON_TYPE).post(JSONObject.class); baseResourse is a WebResource

JACKSON support for Java Generics?

僤鯓⒐⒋嵵緔 提交于 2019-12-12 12:18:27
问题 Currently, I am working on a restFul project, which is schema based. So, we are using JAXB to do a XSD-->JAVA conversion. I have a class as follows: @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "systemResponse" }) @XmlRootElement(name = "RestResponse") public class RestResponse implements Serializable { private final static long serialVersionUID = 1L; @XmlElementRef(name = "SystemResponse", namespace = "http://www.intuit.com/psd/cdm/v1", type = JAXBElement.class)

Wildfly using the Jackson provider instead of Jettison

北城以北 提交于 2019-12-10 11:53:26
问题 I've been using JBoss since version 4.3, I'm currently putting together a dimple demo webapp using Wildfly Beta1 , CDI , JPA and RESTeasy , but I can't get to configure the JSON provider like I use to do in my other JBossAS projects... I added a custom ContextResolver object to my project to correctly configure the JSON producer to serialize dates as ISO-8601 strings: package org.demo.config; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.ext