Modify existing JSON
Posted: Thu Feb 24, 2022 4:15 pm
I have a task where I need to read a database file that has a column that contains a JSON string. I will then execute code based on the value of a key in that string and then modify the value for that key and update the table. All that is pretty straightforward except for "modify the value for that key". I've looked through the service programs but nothing jumps out at me. Is there a procedure that would allow me to change the value for a key?
Example input string:
Task, change the value of "flag" to 2 so it results in this:
I know I could just replace the value using %SCAN and %SUBST but I'd prefer to do it through yajl procedures if possible.
Thanks,
Brian
Example input string:
Code: Select all
{"name1":"value1","name2":"value2","flag":1}
Code: Select all
{"name1":"value1","name2":"value2","flag":2}
Thanks,
Brian