Comments (4)
This works but makes Webpack issue a warning:
WARNING in ./~/jsonpath/jsonpath.js
Critical dependencies:
3:481-488 This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.
@ ./~/jsonpath/jsonpath.js 3:481-488
Additionally, it does not play nice with typescript imports and DefinitelyTyped.
It would make for a much smoother experience if require('jsonpath')
simply worked with Webpack.
Thanks!
UPDATE
There is a better workaround that lets you use require('jsonpath')
or import * as jsonpath from 'jsonpath'
if you use typescript. It requires two changes to webpack.config.js
:
First you need to add the following.
node: {
fs: "empty"
}
See https://webpack.github.io/docs/configuration.html#node for more information.
Then simply add a json-loader
:
loaders: [
...
{
test: /\.json$/,
loader: "json-loader"
},
...
]
This configuration may be trivial for some people but it took me a while to figure out. Now I get a different, less disturbing, warning (the same warning as in the first comment by @Murriouz) but it works fine in the browser:
WARNING in ./~/jsonpath/lib/grammar.js
Critical dependencies:
4:0-7 require function is used in a way in which dependencies cannot be statically extracted
4:18-25 require function is used in a way in which dependencies cannot be statically extracted
@ ./~/jsonpath/lib/grammar.js 4:0-7 4:18-25
from jsonpath.
I would suggest using the pre-built jsonpath.js
library at the root of the repo, instead of asking webpack to build the whole thing from scratch. Does that work for you?
That lib/grammar.js
file is really only useful for generating the static jsonpath
parser itself, not something you probably want at run-time.
from jsonpath.
That works for me. Thanks.
from jsonpath.
I'm using the pre-built jsonpath.js
file but there are some issues..
- When using
$..book[0,1]
, I receive an errorTypeError: _uniq is not a function
. - When using
$..book[-1:]
, I receive all 5 books instead of the last. Note that$..book[(@.length-1)]
works as expected.
from jsonpath.
Related Issues (20)
- Updating the version of static-eval used in jsonpath
- output of stringify function not compatible with query function HOT 1
- require.resolve in aesprim.js seems to be throwing an error
- SQL/JSONPath support HOT 1
- F HOT 1
- Path containing Chinese appears to be unable to extract results
- Unable to use jsonpath with browserify HOT 3
- cannot bundle with CDK/esbuild and use in AWS Lambda HOT 6
- Struggling with "update or create in array" functionality HOT 4
- `jp.parent(o, failingPath)` throws meaningless error
- jp.value doesn't always work
- Error: Can't walk dependency graph: Cannot find module '..' HOT 1
- Cannot use typeof inside filter script
- Found a possible security concern
- Project is failing snyk scans due to SNYK-JS-WORDWRAP-3149973
- `.apply` skips the last path HOT 7
- obj needs to be an object
- member-child-identifier parse wrong !
- Consider implementing RFC 9535 HOT 1
- Square brackets & double quotes in keys
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsonpath.