PDA

View Full Version : read contents of .json file and edit the json



akraman
31 Oct 2012, 12:11 AM
Hi ,
I have a json file workspace.json under a folder, i want to read its contents and edit this json from another js file called locate.js which is located under a different folder. How can i do that ? \

Thanks in advance

James Goddard
31 Oct 2012, 4:09 AM
Use Ext.Ajax.request to load the file. On your success callback call Ext.decode on response.responseText to get a javascript object from the JSON. Then just modify the object as needed.

If you need to save the changes you'll have to have a server side service to write the changes, you could call this with Ext.Ajax.request as well.