Serialize Object to JSON in Java

Customer customer = new Customer();
Product product = new Product();

// Set your values ...

Gson gson = new Gson();
String json = gson.toJson();

Curtomer deserialized = gson.fromJson(json, Customer.class);

References :
http://stackoverflow.com/questions/10930624/creating-json-objects-directly-from-model-classes-in-java

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.