Handle nested Avro record when the one is null

I've got a question about nested Avro records. Actually, I convert a Json file to an Avro one. The Json file is parsed using Jackson. The thing is: the Avro schema contains all the possible fields (including nested ones) the Json could contain an...
more »

2017-10-16 19:10 (1) Answers

jackson @JsonUnwrapped reset values

Jackson @JsonUnwrapped seems to reset the value to some kind of initial default. public class Name { public String first; public String last; } public class Parent { public int age; //@JsonUnwrapped public Name n...
more »

2017-10-16 18:10 (0) Answers

Jackson JSON key as value in Class

I want to use some of the keys in a JSON document as values in a class and I do not want to make use of Map. I have got a JSON document with the following form: { "GateWay": { "API1": { "Infos": "More", "Meta": [1,2,3] }, "API2": { ...
more »

2017-10-16 16:10 (2) Answers

How to map .json to .html url in spring mvc

I am working on a Spring 4.2 MVC application. Here I am trying to invoke a .html extention url that is supposed to return json data. The problem is that I am getting a org.springframework.web.HttpMediaTypeNotAcceptableException when controller invoke...
more »

2017-10-16 09:10 (3) Answers

Accessing json property twice

Consider the following json document: { "a": { "one": "1", "two": "2" }, "b": { "three": "3", "four": "4", } } I need to deserizlize it to the below POJO : class Root{ @JsonAlias({"a","b"}) Node1 node1; @JsonAlias({"a...
more »

2017-10-15 12:10 (1) Answers

How to use Gson instead of Jackson for MockMvc?

I have spent the past day trying to find a solution to this and could not find any online resource that solves this. I am using Gson for Message conversion for my application, which works fine outside of unit testing. I even added a HttpMessageConve...
more »

2017-10-13 18:10 (0) Answers

Convert Map<String, Object> to List<JSONObjects>

I have a function that makes a call to the bamboo rest ap and retreives build results. The method than only retreives the failed tests and put them into a HashMap to than send it to a web app and process it. public Map<String, Object> retriev...
more »

2017-10-13 13:10 (0) Answers

JSON and MultipartFile in POST Controller

I have a controller method, which accepts a multipart post request, containing json and a binary file. It does it's job, but I would like to get rid of explicit objectMapper.readValue() call. @PostMapping public void createEmployee(@RequestParam("em...
more »

2017-10-13 08:10 (1) Answers

Create Xml in java fasterxml

I am using fasterxml.jackson to create xml using POJO. I am expecting output as below: <Customer xmlns=""> <firstname>FirstNameA</firstname> <middlename>LastNameA</middlename> </Customer> But getting out...
more »

2017-10-12 14:10 (1) Answers

Jpa entity relationship caused endless loop

I am using spring data jpa to build my project. There is a User entity and a Biz entity. @ManyToOne(fetch=FetchType.LAZY,cascade = CascadeType.ALL) @JoinColumn(name = "user_id") private UserInformation belongUser;//所属用户 This code above is ...
more »

2017-10-12 04:10 (2) Answers

Validating yaml config file

I want to have a configuration file in yaml format. I want to have a configuration class in java that should be filled with the values of the file above. I already found Jackson to pretty much exactly do this. However I want to make sure that the ...
more »

2017-10-11 23:10 (0) Answers

YAML Jackson - Anchor keys of Array

I am trying to parse a YAML file into an object. Even though Online YAML Parser tells me that it is parsable the way I want, Jackson YAML parser refuses to give me what I want. Here is the YAML File : - nom: "service1" etats : &e1s1 - no...
more »

2017-10-11 15:10 (1) Answers

Jackson JSON / XML root elements are not the same

First, note that my issue is very similar to: Jackson xml and json root element but differs only slightly where I only want a single root element for JSON. Here is my UserList class: @XmlRootElement(name = "users") @JsonRootName(value = "users") @...
more »

2017-10-10 23:10 (0) Answers

Date timezone with Spring boot and Jackson

I'm developing a spring boot application that handles dates. When I submit an Appointment object that has a startDateTime and an endDateTime (Both are of type java.util.Date) I send a format like this: { "lastName": "Jhon", "firstName": "Doe...
more »

2017-10-09 21:10 (1) Answers

Stop Jackson from changing case of variable names

I am using Jackson in Spring to serialize my class to JSON. When I serialize a class like the example below, Jackson is changing the names of certain fields from Camel Case to lower case. I know I can work around this by creating custom (de)serialize...
more »

2017-10-09 19:10 (2) Answers

Deserializing from JSON using foreign key

I have a many to one relationship: A *<-->1 B and I want to deserialize A from a JSON having B's primary key (B exists in db with that primary key): { "b": 1 } I have tried the following: @Entity @Table(name = "table_a") @JsonIdentityInfo(...
more »

2017-10-09 18:10 (1) Answers

Jackson: Serialise ArrayList not working?

I am referring to this example here to serialize my object. I have this initially and it works. public class MyClass implements Serializable { private String mediaitem_id; private String customer_id; private int quantity; public My...
more »

2017-10-09 10:10 (1) Answers