Spring/Springboot provides a good framework in order to develop web application
it is very easy to implement ReSTfull HTTP calls. In these calls, it is even possible to provide data-object such as
public class User {
private long id;
private String name;
long getId() { return id; }
long getName() { return name; }
long setId(long id) { this.id = id; }
long setName(String name) { this.name = name; }
}
this data-object is serialized/deserialized to JSON automatically by the framework without writing any line of code
I would like to know what is the code/module used for that "automatic JSON serialization" and whether it is possible to reuse it for a completely different purpose?
Thanks for help
CodePudding user response:
As mentioned in the previous answer by Todoy, Spring uses Jackson to serialize/deserialize java objects.
You can use Jackson without using it with Spring. There are other java libraries that you can use for the same purpose (e.g. Gson) in case you want to explore other option.
Jackson Documentation https://github.com/FasterXML/jackson-docs
Cheers, Karl
CodePudding user response:
By default, spring will use Jackson for both serialized/deserialized.
A quick way to verify this would be by using:
mvn dependency:tree
From there you can see what dependancies are being pulled in by spring.