I need to construct a javax.json.JsonObject with following data,
{
"name": "John",
"age": 20,
"interests": [ "Reading", "Mountain Biking", "Hacking" ]
}
Code for the same ?
JsonObject personObject = Json.createObjectBuilder()
.add("name", "John")
.add("age", 20)
.add("interests",
Json.createArrayBuilder().add("Reading")
.add("Mountain Biking")
.add("Hacking")
.build()
)
.build();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.