Skip to content
Advertisement

Tag: jackson

Jackson deserialization issue for ZonedDateTime

I’ve the following field in a class I use during deserialization of a service that I’m consuming. The service I’m consuming may return a Date or DateTime using the pattern: yyyy-MM-dd’T’HH:mm:ss.SSSZ Let me give 2 examples of what the service returns: 2015-11-18T18:05:38.000+0200 2015-11-18T00:00:00.000+0200 While first one works well, the latter causes the following exception to be thrown during deserialization: java.time.format.DateTimeParseException:

Jackson: Deserialize BigDecimal as plain String using annotation

I have this REST response: And this POJO: I’m using Spring RestTemplate with MappingJackson2HttpMessageConverter. With response above, prevValue is deserialized as a String like 1.0104401E7, in scientific notation. I want it to be deserialized without scientific notation. Is there a way to do this using Jackson annotations? Answer You can use the @JsonFormat annotation:

Jackson Not Overriding Getter with @JsonProperty

JsonProperty isn’t overriding the default name jackson gets from the getter. If I serialize the class below with ObjectMapper and jackson I get As you can see the JsonProperty annotation has no effect Putting @JsonProperty on the String itself doesn’t work either. The only way it seems that I can change the name is by renaming the getter, the only

Logging JSON-RPC calls using jsonrpc4j

I’m sure that if you have used jsonrpc4j (outside a spring container) you will recognise the following standard pattern. I am trying to create a log file containing all the JSON requests and JSON responses. i.e. I’d like to log the incoming JSON RPC request before it is deserialised and log the out going request just after it is serialised.

DynamoDB JsonMarshaller cannot Deserialize List of Object

I have a Java class which is the data-model of a table in DynamoDB. I want to use the DynamoDBMapper to save and load items from Dynamo. One member of the class is a List<MyObject>. So I used the JsonMarshaller<List<MyObject>> to serialize and de-serialize this field. The list can be successfully serialized by the JsonMarshaller. However, when I try to

Check if JSON is valid in JAVA using Jackson

I have a JSON string which I am storing it in DB as a string. In front-end, I am rendering this JSON as object. I am using: String : Is there any way I can check If JSON is valid or not in JAVA? One thing to be noted here is that, I don’t have a schema defined for JSON

Java 8 LocalDate Jackson format

For java.util.Date when I do then in JSON request when I send it works. How should I do this for Java 8’s LocalDate field?? I tried having It didn’t work. Can someone please let me know what’s the right way to do this.. Below are dependencies Answer I was never able to get this to work simple using annotations. To

JSONPath resolver for Java objects

How can I get a value from an Java object instead from a JSON string by applying a JSONPath expression? I receive a Java object that is created from a JSON string (via Jackson, no way to influence it): I further have some JSONPath expressions as Java Strings reflecting values in the object (they might be much more complex): I

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

Advertisement