Link.java
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({ "rel", "href","method" })
public class Link {
@JsonProperty("rel")
private String rel;
@JsonProperty("href")
private String href;
@JsonProperty("method")
private Method method;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
I have this third party class with fasterxml jackson annotations. I can convert a given object into a string using the specified toString() method. Is there any way of using that String to get an object of type Link?
Note: The object itself has an embedded object (which has several more embedded objects) and these too needs to be converted into a Method object from the string itself.
new ObjectMapper().readValue(jsonString, Link.class);
– FrigateToStringBuilder
can be configured to output JSON, whichObjectMapper
would be able to consume. – Rapid