Skip to content

Tag: json

Groovy HTTP ResponseParseException not found

I am trying to make simple GET request using groovy HTTP request. I am expecting JSON response in this form: So far I have done this in my code: and I am always getting this response: I have googled and found out that it’s problem related to groovy and this problem was not occurring before version 2.3.0…

File structure listing as Json

How can I get a local directory listing as a Json? So If I provide a folder, I want to see all its subfolders and files in a json tree type object. Please note: I don’t want just the list with file paths. Thank you! Answer So @CommonsWare put me in the right direction and I was able to do

Jackson Serialize Field to Different Name

I have this JSON to deserialize: I want to serialize it to 2 different formats: [A] [B] I’m able to serialize it to 1 format: [A] only or [B] only. Here’s my code to serialize it to [B]: I read about JsonView here http://www.baeldung.com/jackson-json-view-annotation (section ‘5. Customize JS…

How can I prevent gson from converting integers to doubles

I’ve got integers in my json, and I do not want gson to convert them to doubles. The following does not work: The output is not what I want: Is there a way to have Integers instead of Doubles in my Map? Edit: not all my fields are integer. I’ve modified my example accordingly. I’ve read quit…

How to serialize nested ObjectId to String with Jackson?

There are many questions concerning conversion from ObjectId to String with jackson. All answers suggest either creating own JsonSerializer<ObjectId> or annotating the ObjectId field with @JsonSerialize(using = ToStringSerializer.class). However, I have a map that sometimes contains ObjectIds, i.e.: I w…

Using spring converter in @RequestBody

Is it possible to enforce Converter ( org.springframework.core.convert.converter.Converter) to finish json object mapping? Json code example: where somename – string, id – integer value mapping to : Converter code example: What I want to achieve is to map that json to the object which will have au…

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…