How to Convert List to JSON in Java using Gson API

Convert List to JSON in Java

This is a simple program about, How to Convert List to JSON in Java using Gson API. The Gson API can be downloaded from here

Product.java

ListConversion.java

Output

[{“productId”:101,”productName”:”Item 1″,”productDesc”:”About Item1″},{“productId”:102,”productName”:”Item 2″,”productDesc”:”About Item2″},{“productId”:103,”productName”:”Item 3″,”productDesc”:”About Item3″}]

References

1. Gson API JavaDoc