I'm currently reading in a JSON object file, and I'm trying to modify the elements and write back to it. I know this can easily be done with a MongoDB, but I need to do it with JSON files. My current structure looks like this:
{
"lastupdated": "Thu Nov 20 2014 10:57:08 GMT-0500 (EST)",
"restaurants" : {
"McDonalds": {
"Americas": [
"Atlanta",
"Cambridge",
"Dayton"
],
"Asia": [
"Seoul",
"Shanghai",
"Singapore",
"Tokyo"
],
"Europe": [
"Milan",
"Madrid",
"Amsterdamn"
]
},
"BurgerKing" : {
"Americas": [
"Atlanta",
"Boston",
"Charlottesville"
],
"Asia" : [
"Hong Kong",
"Singapore",
"Tokyo"
],
"Europe" : [
"Rome",
"Madrid",
"Dublin"
]
}
}
}
I want to be able to do something like json.add(object.restaurants.McDonalds.Americas.("Washington D.C.") and this will update tte file to look like:
{
"lastupdated": "Thu Nov 20 2014 10:57:08 GMT-0500 (EST)",
"restaurants" : {
"McDonalds": {
"Americas": [
"Atlanta",
"Cambridge",
"Dayton",
"Washington D.C."
],
I'm currently using FS to read it in and store it as a json object