Javax.ws.rs.client.Entity json () for string

I use jersey to send some objects to a remote REST service via json, here is the client:

Invocation invocation = buildingWebTarget.request(MediaType.APPLICATION_JSON). buildPut(Entity.json(tmpEntity)); 

on the other hand, I get an object, but with all fields set to null. TmpEntity has no null fields, so I'm trying to debug what Entity.json () does, is there a way to print the result of Entity.json () as a String ??

Using

 log.info(Entity.json(tmpEntity).toString()) 

returns only gibberish.

PS:

My tmpEntity is like:

 @XmlRootElement @Entity public class City implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String name; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } } 
+5
source share

Source: https://habr.com/ru/post/1241819/


All Articles