I'm using Jersey to post some entities to a remote REST service through json, here is the client:
Invocation invocation = buildingWebTarget.request(MediaType.APPLICATION_JSON).
buildPut(Entity.json(tmpEntity));
at the other side I receive the entity but with all fields set to null. The tmpEntity has no null fields so I'm trying to debug what Entity.json() does, is there a way to print as String the result of Entity.json()??
Using
log.info(Entity.json(tmpEntity).toString())
only returns 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;
}
}
LoggingFilter
with the client to see the request body, to see if it's even a problem with the client side.client.register(new LoggingFilter(Logger.getAnnonymousLogger(), true));
– AnonClient client = ClientBuilder.newClient()
... It's theClient
instance variable – AnontmpEntity
class look like? So are you able to get it to work in a standalonemain()
program. I'm not getting where Proguard fits into this. It almost sound like you're saying that Progaurd may be the cause. – Anonpublic City(){ super();}
. anyway i uses jackson to json converting utility. here example:public String toJson(Object input){ StringWriter sw = new StringWriter(); ObjectMapper mapper = new org.codehaus.jackson.map.ObjectMapper(); try { mapper.writeValue(sw, input); } catch (JsonGenerationException e) { log.error(e.getMessage(), e); } catch (JsonMappingException e) { log.error(e.getMessage(), e); } catch (IOException e) { log.error(e.getMessage(), e); } return sw.toString(); }
– Melancon@JsonProperty("id")
. Jackson usually introspects bean properties. If proguards mangle them, then the reading is affected. If the properties are annotated, then it doesn't matter what the properties are mangled to, as the name in the annotation value will be used. – Anon