Coder Social home page Coder Social logo

Comments (9)

jdevillard avatar jdevillard commented on September 28, 2024

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.

ImAbhishekTomar avatar ImAbhishekTomar commented on September 28, 2024

@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.

jdevillard avatar jdevillard commented on September 28, 2024

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.

ImAbhishekTomar avatar ImAbhishekTomar commented on September 28, 2024

Does this package available for dot net core? https://www.npmjs.com/package/@metrichor/jmespath or there is any workaround to access Root value?

Screenshot 2022-02-16 at 11 08 01 PM

from jmespath.net.

jdevillard avatar jdevillard commented on September 28, 2024

Does this package available for dot net core? https://www.npmjs.com/package/@metrichor/jmespath or there is any workaround to access Root value?

Screenshot 2022-02-16 at 11 08 01 PM

no it's specific to javascript implementation.

We will see how to implement this as well on the dotnet version

from jmespath.net.

glenveegee avatar glenveegee commented on September 28, 2024

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.

springcomp avatar springcomp commented on September 28, 2024

@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.

springcomp avatar springcomp commented on September 28, 2024

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.

springcomp avatar springcomp commented on September 28, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.