How to use fully functioning JsonPath in angular 2+?

Viewed 374
1 Answers

import jsonPath worked after -

import * as jsonPath from 'jsonpath/jsonpath';

JsonPath plush also worked JSONPath-plus which is same as of Jsonpath. I have following coding snippet which is working for me-

install JSONPath-plus

npm install jsonpath-plus

angular.json file

"scripts": [
    "node_modules/jsonpath-plus/dist/index-umd.js",
    "src/assets/js/jsonpath.js"
]

jsonpath.js have following code -

function jsonPath() {
  return JSONPath;
}

Now use this function in ts file with declaring it like below -

declare const jsonPath: any;
// use it like
 jsonPath().JSONPath(path, json);

 
Related