Is there a way to append to a json object in a file? -


i using file hold json data program generating. structure this:

{"alldata" : {     "data1": [{"d": 10}, {"d": 20}, {"d": 30}],     "data2": [{"d": 100}, {"d": 200}, {"d": 300}],     "data3": [{"d": 1000}, {"d": 2000}, {"d": 3000}]     } } 

i generating , writing data constantly. need read data file use in program.

the problem whenever want add new data 1 of data members of alldata object program have read in whole object file , store json object in memory, access data member, append new piece of data, , write whole object file.

i able add data file more efficiently bypassing bringing whole object memory. think better open file appending , add piece of data it. however, don't think work because appending end of file screw format of json.

my initial thought create 3 separate json files, data1.json, data2.json, , data3.json objects in them, this:

data1.json {"d": 10} {"d": 20} {"d": 30} 

and few times need read data use in program, open files , reconstruct original json object.

is there way append json object in file? preferred way of adding json object in file? there file format other json allow type of behavior?


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -