Reputation: 19463
I have a JSON object, something like:
{
"myData":[1,2,3],
"externalData1":...,
...
"externalDataN":...
}
I want to read this JSON, update my data (lets say adding number "4") and save the JSON without knowing anything about the external data fields.
I know that for parsing I can use the @JsonIgnoreProperties
but then I will loss the data on the save. Is there a way to do that without going manually over the TreeModel?
Thanks.
Upvotes: 2
Views: 680
Reputation: 1699
Use org.json:
JSONObject root = new JSONObject(json);
JSONArray myData = (JSONArray) root.get("myData");
myData.remove(0);
myData.put(4);
System.out.println("root = " + root.toString());
Upvotes: 2
Reputation: 6363
You can use json-simple
which won't give you the data binding to a POJO, but it will still be a lot more convenient than doing the parsing your self.
Upvotes: 1