Monday, 10 April 2017

Update values in multiple large JSON files

I have a folder with several large JSON files and would like to optimize them. I was using gulp with gulp-replace to remove white space.

The files contain a large JSON object where under some sub-property I would like to update some values. Since the files are large, I was looking into JSON streaming to keep the memory footprint low. There are several JSON streaming libraries like JSONStream, BFJ, Oboe and stream-json available.

JSONStream seemed the easiest one to use, as it allowed path matching with placeholders but the matched value seems to be only for extracting data and not for updating.

So what I'd like to achieve is streaming data in, parsing some specific sub-object, update its values, stringify that sub-object again and save the whole data with updated values back on disk.



via Matthias Tylkowski

No comments:

Post a Comment