0.0.2 • Published 7 years ago

json-path-position-info v0.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

json-path-position-info

Greenkeeper badge Module to provide the position info of a JSONPath within a blob of JSON

Usage

const jppi = require('json-path-position-info');

const json = {
  prop1: 'one',
  prop2: 2,
  prop3: {
    three: true
  },
  prop4: [
    {
      index: 1
    },
    {
      index: 2
    }
  ]
};

const data = jppi(json, 'prop3.three', '.', '  ');
console.log(data);

// Output: { source: '{\n  "prop1": "one",\n  "prop2": 2,\n  "prop3": {\n    "three": true\n  },\n  "prop4": [\n    {\n      "index": 1\n    },\n    {\n      "index": 2\n    }\n  ]\n}',
  line: 5,
  column: 5,
  pos: 46 }