/jesuis

Object matching from JSON.

Primary LanguageJavaScriptMIT LicenseMIT

jesuis

git npm travis

Library for JSON parsing based on object matching. Outputs lineage trace as state progressed during search.

Example

Check out the example.js and test.js files for more examples.

var jesuis = require('jesuis');

var y = {
	a: 1,
	b: [1,2],
	c: [3,4,{b: true}]
}

jesuis.start(y, {b: true});

Reading Output

The outupt is written to ./tmp/jesuis.json file for accomodating drill-down analysis to identify the origin of the matched items. Lineage trace is stored per object in the json[idx].ancestors array, and that you may inspect for deciphering the origin of the JSON object the term was matched.

The example above would generate the following output:

[
    {
        "objectSearch": true,
        "node": {
            "b": true
        },
        "ancestors": [
            "root",
            {
                "a": 1,
                "b": [
                    1,
                    2
                ],
                "c": [
                    3,
                    4,
                    {
                        "b": true
                    }
                ]
            },
            [
                3,
                4,
                {
                    "b": true
                }
            ],
            {
                "b": true
            }
        ],
        "match": {
            "b": true
        }
    }
]

License

aug2uag © 2015, Licensed under MIT.