From
echicken@VERT/ECBBS to
Mortifis on Sat Jun 20 16:16:15 2020
Re: read json from fileã By: Mortifis to All on Sat Jun 20 2020 11:24:37ãã Mo> I have a local json file that I'd like to search for a matching unknown recordã Mo> # without having to read in the entire object (the file has over 200,00 recordsããIf your file looks like this:ãã{"a":0,"b":1,"c":2,"d":3}ããYou basically need to parse the whole thing. Or write your own special parser.ããIf your file is like this:ãã{"a":0,"b":1,"c":2,"d":3} {"e":4,"f":5,"g":6,"h":7}ããThen those are two separate JSON strings on adjacent lines. In which case you can read the file line by line, and each line will work with JSON.parse.ãã---ãechickenãelectronic chicken bbs - bbs.electronicchicken.comã þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.comã
From
echicken@VERT/ECBBS to
Mortifis on Sat Jun 20 22:57:44 2020
Re: Re: read json from fileã By: Mortifis to echicken on Sat Jun 20 2020 21:43:56ãã Mo> }, .... that's the 1st three records of 209,578 records ... gotta read allã Mo> 209,578 records (1 million, 8 hundred 86 thousand, 2 hundred 13 lines) ? ...ã Mo> bleh ... lolããNot necessarily, but you'll need something more than what we have on hand.ããStreaming JSON parsers for handling really large files are a thing, but I don't know if there's one that can be readily ported to our environment.ããJSON.parse() only wants to parse a complete JSON string. You'd need to be able to pre-process what you're reading from the file to be sure that JSON.parse() won't choke on it.ããThat's tricky to do in a generic way that could handle any old JSON you throw at it.ããEasier if you do it as a custom job for this particular file, and if this file is just a flat array of objects, all with the same keys and types of values. It's either going to be a bit complicated but fairly solid, or simple and hacky and maybe not super reliable.ãã---ãechickenãelectronic chicken bbs - bbs.electronicchicken.comã þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.comã