Open pankajashankar opened 5 years ago
think the answer to this is to follow the docs exactly:
// https://github.com/dchester/jsonpath#jpqueryobj-pathexpression-count
import jp from 'jsonpath'
jp.query(BLAH)
If you destructure the import (as i was):
import {query} from 'jsonpath'
query(BLAH)
It gives the error you describe. I'd say it was down to webpack treeshaking or something but declaring as an external
didn't help either..
in my case I have to import jsonpath
in the following way
const jsonpath = require("jsonpath")
I had the same issue because I was calling :
jp.query.call(null, data, path)
When I changed this
parameter from null
to jp
it solved the problem.
jp.query.call(jp, data, path)
btw, my import is import jp from 'jsonpath'
I had the same issue because I was calling :
jp.query.call(null, data, path)
When I changedthis
parameter fromnull
tojp
it solved the problem.jp.query.call(jp, data, path)
btw, my import is
import jp from 'jsonpath'
belated update from my initial post. I did that change recently also and got it to work. so in conclusion it seems like importing individual function does not work, instead you have to import the entire content.
I think this needs to be fixed so that tree shaking can be done to only use functions that are required..
Hi, Premise:
Not sure why it gives that error but when I modify the index.js under nodemodules\jsonpath to change this to JSONPath.prototype, and re-run I do not get the error.
Please let me know what is the issue here. Also mainly what is the solution.
--Thanks