jackson serializes long x = 1234 to {x:1234} For several reasons I need {x:"1234"}
any jackson annotation?
thanks.
Note that Jackson does not use java. io. Serializable for anything: there is no real value for adding that. It gets ignored.
The simple readValue API of the ObjectMapper is a good entry point. We can use it to parse or deserialize JSON content into a Java object. Also, on the writing side, we can use the writeValue API to serialize any Java object as JSON output.
let's serialize a java object to a json file and then read that json file to get the object back. In this example, we've created Student class. We'll create a student. json file which will have a json representation of Student object.
The following annotation could be used to serialize a long as a string:
@JsonSerialize(using=ToStringSerializer.class)
public long getId() {
return id;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With