Use javascript to update a json file
To edit a JSON file:
- Open the file with php
- Send the contents to the browser (Just dump it as string in a variable in a script tag)
- Parse the JSON with JavaScript (onload -> get the string from the script tag)
- Edit the object
- Convert it to a JSON string again
- Send it back to php
- Have php overwrite the file.
It's a shame you can't just edit the file directly in php, that'd render steps 2-6 unnecessary, you'd just parse, edit, and encode the JSON in php.
Edit: Since you seem to have the data in JavaScript already, steps 1-3 are accounted for.