Skip to content
Advertisement

Tag: json

Different names of JSON property during serialization and deserialization

Is it possible: to have one field in class, but different names for it during serialization/deserialization in Jackson library? For example, I have class “Coordiantes”. For deserialization from JSON want to have format like this: But when I will serialize object, result should be like this one: I tried to implement this by applying @JsonProperty annotation both on getter and

In Java, how can I combine two JSON arrays of objects?

I have several string each containing a JSON representation of an array of objects. Here’s an example in code to illustrate, though this is not my actual code (the JSON strings are passed in): I need to combine those two JSON arrays into one large JSON array. I could treat this as a String manipulation problem and replace the inner

Jackson JSON do not wrap attributes of nested object

I’ve got following classes: When I serialize Container class using Jackson I get But I need the result to be: Is it possible (without adding Container.getDataId() method)? If so, how to do it? update I’ve tried to create custom JsonSerializer<Data> but the result was same as before I’ve also tried to add @JsonSerialize annotation above Data class, then above getter

How to use Jackson to deserialise an array of objects

The Jackson data binding documentation indicates that Jackson supports deserialising “Arrays of all supported types” but I can’t figure out the exact syntax for this. For a single object I would do this: Now for an array I want to do this: Anyone know if there is a magic missing command? If not then what is the solution? Answer First

Deserializing JSON into object with overloaded methods using Jackson

I am attempting to deserialize a JSON object stored in CouchDb using Jackson. This object needs to deserialize into a pojo that contains overloaded methods. When I attempt to retrieve the object from couch and do the deserialization I get the following exception: org.ektorp.DbAccessException: org.codehaus.jackson.map.JsonMappingException: Conflicting setter definitions for property “multiplier”: com.db.commodities.framework.sdos.model.security.EqOpt#setMultiplier(1 params) vs com.db.commodities.framework.sdos.model.security.EqOpt#setMultiplier(1 params) I tried to annotate

Converting JSON data to Java object

I want to be able to access properties from a JSON string within my Java action method. The string is available by simply saying myJsonString = object.getJson(). Below is an example of what the string can look like: In this string every JSON object contains an array of other JSON objects. The intention is to extract a list of IDs

Advertisement