Nirvana Playing Madonna

    extract-json-string

    1.0.1 • Public • Published

    extract-json-string

    Simple module for extracting JSON objects from a string dump.

    Usage

    Return an array of objects from a string containing stringified JSON objects.

    var ejs = require('extract-json-string')
    
    const logdump = `
        18:28:54,289 [83] INFO Files Process Start.... 
        // having mismatched braces { works
        // having erroneous JSON-like { key : value } doesn't
        // break the program
        18:28:55,289 [83] INFO Files Process Start....
        18:28:56,289 [83] INFO Files Process Start....
        {
            "name" : "Nathan"
            "likes" : ["guitar", "Yuqing", "Tori"]
            "age" : 25
        }
        18:28:57,289 [83] INFO Files Process Start....
        18:29:00,289 [83] INFO Files Process Start....
        {
            "name" : "Yuqing"
            "likes" : ["China", "brain", "eyeballs"]
            "age" : 21
        } etc...
    `
    var objs = ejs.extract(logdump)
    console.log(objs)
    

    Updates

    Install

    npm i extract-json-string

    DownloadsWeekly Downloads

    56

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • esoodev