I am using the JSON-simple library to parse the Json format. How can I use or modify something to a JSONArray? For e.g. consider the following json
"Place": [
{
"name": "owner 1"
},
{
"name": "owner 2"
}
],
"branch": [
{
"name": "sucursal",
"employe": [
],
"clients": [
]
},
I need to add some clients and in the future modify them. How to achieve this?
CodePudding user response:
Simply create a pojo class in the same format.
Classs Pojo{
private List<Place> place;
private List<Branch> branch;
// other fields
}
and use writeValueAsString() from your object mapper to convet it to json.