How to Convert Set to JSON in Java using GSON API

Convert Set to JSON in Java

In this example, We will show simple example program about, How to convert set to json in java

1) Simple POJO (Plain Old Java Object) Class

2) Converting Set Object to JSON String


[{“pizzaId”:101,”pizzaName”:”Chicken Pizza”,”pizzaPrice”:150.0},
{“pizzaId”:105,”pizzaName”:”Pepproni Pizza”,”pizzaPrice”:125.0},
{“pizzaId”:103,”pizzaName”:”Cheese Pizza”,”pizzaPrice”:100.0},
{“pizzaId”:102,”pizzaName”:”Veg Pizza”,”pizzaPrice”:120.0},
{“pizzaId”:104,”pizzaName”:”Onion Pizza”,”pizzaPrice”:80.0}]


1. Java Set API
2. Java HashSet API
3. JSON API JavaDocs