You have to write some kind of JSON parser where you have to read character by character to parse the file;
var readable = fs.createReadStream("jsonfile.json", {
encoding: 'utf8',
fd: null,
});
readable.on('readable', function() {
var chunk;
while (null !== (chunk = readable.read(1))) {
//chunk is one character
if(chunk == "["){ //JSON array is started }
if(chunk == "{"){ //Handle JSON object started}
//In between you can parse each character until you get a `:` character to
//identify the key and from there up to a comma it is value. (** Considering the simple JSON file example you provided**)
if(chunk == "}"){ //Handle JSON object end}
if(chunk == "]"){ //Handle JSON array end}
}
});
But I suggest you to go some kind of library for this. Else it will itself a separate project. Anyway for you example JSON type, you can write one yourself as the format is quite simple and you know what can be the issue (extra comma).
Generalize solution will be much more difficult.