JSON-Simple. Modify and use complex object

81 Views Asked by At

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?

1

There are 1 best solutions below

0
Karamveer Gahlot On BEST ANSWER

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.