I have a json file which I need to update its numerical values and write back to new file.This is the sample script I have
[
{
"type": "flipImage",
"image": "img/new.jpg",
"trigger": "{{10,80},{300,350}}",
"animationDuration": "1.0"
}
]
The numerical values of "trigger": "{{10,80},{300,350}}" need to update to some other value. I am managed to get the value by json_decode() in php . After decoding it is returning the value {{10,80},{300,350}}
This is script for decoding
$json_data = file_get_contents('json.txt');
$encoded_data = json_decode($json_data,true);
echo $encoded_data[0]['trigger'];
But I got stuck in the updating part . How can I split the value, then update and write back the updated json file?
Any help highly appreciable.
Update First I need parse that numerical values then I have some calculations on it. After calculation write back the entire json to new file
{{10,80},{300,350}}if you just want to overwrite it, do you?