Comments (9)
Hello,
thanks for opening this issue, I would like to reproduce the issue.
I understand that q2 seem to be the "transform expression" and it seems to be an parsing issue with some special characters.
Could you provide a sample input? or does it have sensitive information?
I would like to be sure what you meant using the "$" on your input.
from jmespath.net.
@jdevillard Sample JSON data. I am validating my query with this editor https://api.gopipeline.io/jmespath-tester
{
"reporting_entity_name": "***********",
"reporting_entity_type": "***********",
"plan_name": "***********",
"plan_id_type": "***********",
"plan_id": 1111,
"plan_market_type": "***********",
"last_updated_on": "2021-08-30",
"in_network" : [
{
"negotiation_arrangement" : "***********",
"name" : "***********",
"billing_code_type" : "***********",
"billing_code_type_version" : "201",
"billing_code" : "***********",
"description" : "***********",
"negotiated_rates" : [ {
"providers" : [ 11111111,22222222,4444444,666666,777777,1111 ],
"tin" : "***********",
"service_code" : "***********-***********",
"negotiated_price" : {
"negotiated_type" : "***********",
"negotiated_rate" : 10.000,
"expiration_date" : "9999-12-31"
}
}]
},
{
"negotiation_arrangement": "***********",
"name": "***********",
"billing_code_type": "***********",
"billing_code_type_version": "201",
"billing_code": "***********",
"description": "***********",
"negotiated_rates": [
{
"providers": [2342432, 234234, 243234, 234234, 24324, 424324234],
"tin": "023432324324",
"service_code": "***********-***********",
"negotiated_price": {
"negotiated_type": "***********",
"negotiated_rate": 10.0,
"expiration_date": "9999-12-31"
}
}
]
}
]
}
from jmespath.net.
Thanks for this info and for providing the link to the tester.
The online tester you mention use the library available at https://www.npmjs.com/package/@metrichor/jmespath
This library provide some extension for the initial spec like this one :
Root value access with $ symbol
search({foo: {bar: 999}, baz: [1, 2, 3]}, '$.baz[*].[@, $.foo.bar]')
// OUTPUTS:
// [ [ 1, 999 ], [ 2, 999 ], [ 3, 999 ] ]
However, it could be a good idea to include this extensions in the .Net Specification.
We're currently checking with the team how specification could be extended and re-integrated in the initial spec to be sure that every language follow the same spec.
Thanks a lot.
from jmespath.net.
Does this package available for dot net core? https://www.npmjs.com/package/@metrichor/jmespath or there is any workaround to access Root value?
from jmespath.net.
Does this package available for dot net core? https://www.npmjs.com/package/@metrichor/jmespath or there is any workaround to access Root value?
no it's specific to javascript implementation.
We will see how to implement this as well on the dotnet version
from jmespath.net.
Hey folks, The $
symbol is definitely not standard JMESPath spec but there are a number of JMESPath libraries developed in the community that have extended the spec to include it because it's easy to implement and really useful. Another low hanging fruit that many folks implement (and you might consider) is a means to define custom functions.
from jmespath.net.
@glenveegee Thanks for the feedback.
JmesPath.Net
does support custom functions. The parser includes a hook to register custom functions. Builtin functions are actually registered using this mechanism on startup.
Please, look at this repository for samples.
We plan to draft a JEP to submit a proposal that the official specification implements the $
symbol.
from jmespath.net.
We are discussing whether to support the $
keyword.
However it seems it would be better served by extending the let()
function from the Lexical Scoping proposal by supporting expressions like:
let({root: @}, &...)
from jmespath.net.
@ImAbhishekTomar A new version of JMESPath.NET has been released.
It includes an implementation of the let()
function that lets you capture any lexical scope you need for later use.
This may help you work around the non-standard $
symbol.
You will need to register the let()
function:
var parser = new JmesPath();
parser.FunctionRepository
.Register<ItemsFunction>()
.Register<ToObjectFunction>()
.Register<ZipFunction>()
.Register<LetFunction>()
;
The example you refer to can be written like so:
search( let({dollar: @}, &baz[*].[@, dollar.foo.bar]), {"foo": {"bar": 999}, "baz": [1, 2, 3]})
-> [[1,999],[2,999],[3,999]]
Or, in C#
var document = "{\"foo\": {\"bar\": 999}, \"baz\": [1, 2, 3]}";
var expression = "let({dollar: @}, &baz[*].[@, dollar.foo.bar])";
var result = parser.Transform(document, expression);
Console.WriteLine(result);
from jmespath.net.
Related Issues (20)
- Target netstandard 2.1 HOT 6
- Doesn't properly parse for max_by HOT 1
- Nuget package should have addtional metadata HOT 2
- Add Net standard 2.1 as TFM HOT 1
- Consider implementing a dependency injection mechanism to simplify code.
- System.Text.Json support HOT 11
- Convert Expression to JMESPath string HOT 5
- netstandard1.3 HOT 3
- Bug in .NET with a number comparison HOT 3
- Array parsing does not work as expected HOT 2
- JMESPath.Net does not handle Unicode surrogate pair characters correctly.
- Behaviour issue when using `null` on the lhs of a `pipe-expression`
- Add extension point to register custom function implementation HOT 4
- lower() function uses ToLowerInvariant incorrectly
- String Slice fails with 'Index was outside the bounds of the array.' error HOT 3
- Hash is calculated each time even for comparison with Null token
- JmesPath class might not be thread-safe HOT 3
- Trim() function (and trim_left/trim_right) has state that affects next invocations
- C# Using JmesPath (1.0.308) Transform(string json, string expression) does not filter on integers when using `tick` delimiter. HOT 2
- Add async support for custom functions HOT 1
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 jmespath.net.