regex - Grabbing a number from .JSON -


i have long list of data, in following format:

[ {     "id": "1234",     "date/time": "2016-07-18 18:21:44",     "source_address": "8011",     "lat": "40.585260",     "lng": "-105.084420", } ] 

and creating script extract values out of each line. example, if line contains "id": want able store value "1234" variable, can store in different format.

here code detect "id":

'use strict';  let linereader = require('line-reader');  //.json variables input file let id;   //begin creating new object console.log('var source = {'); //output file linereader.eachline('dataout.json', function (line, last) {      //detect id, , print out in new format     if (id =~ /^id:$/) {         console.log('id: "') + console.log('",');     }      //done     if (last) {         console.log('}');         return false; // stop reading     } }); 

once detect id, i'm not sure how can obtain value follows "id" on line.

how can store values on line, after detect line on?

unless json file stupidly big, can require , it's in memory js object.

var obj = require('./dataout.json');  // first element console.log(obj[0]); 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -