Just to update, I tried the JSON Parser to read the nodes and modify those. 
But, I am struggling with updating those nodes in the file again, because 
with JSONParser, I can read, and JSONGenerator just overwrites the entire 
file.

On Monday, October 14, 2019 at 5:28:09 PM UTC-4, Lalit Patil wrote:
>
> Hi
>
> I am trying to use Jackson streaming API to update data in a JSON file. I 
> want to achieve this without reading the entire file or creating a copy of 
> the file. For example, I might want to update the age of index 2 below from 
> 40 to 20. I could read the entire tree, and then update the node and write 
> the entire tree back. However, I am hoping to read each node and when I 
> find index 1, update only that index and write in the same file without 
> having to write the rest of the data.
>
> Is it possible to achieve this using Jackson?
>
>
> [
>   {
>     "index": 0,
>     "age": 36,
>     "name": {
>       "first": "Hernandez",
>       "last": "Rutledge"
>     }
>   },
>   {
>     "index": 1,
>     "age": 40,
>     "name": {
>       "first": "Clarissa",
>       "last": "Kent"
>     }
>   },
>   {
>     "index": 2,
>     "age": 34,
>     "name": {
>       "first": "Carver",
>       "last": "Melton"
>     }
>   }
> ]
>

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jackson-user/de10cf7a-e2bf-453d-83c9-493239186e17%40googlegroups.com.

Reply via email to