Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    lakshmi Pendyala
    @lpendyala_gitlab
    this expression is in yaml file
    even for me it's working good when I queried this command cat /tmp/test.json | jp '"987654321012"."us-east-1"'
    James Saryerwinnie
    @jamesls
    oh, maybe just quote the whole value in the yaml file. I'm guessing yaml's thinking it's two separate strings. So:
    expr: '"{account_id}"."{region}"'
    lakshmi Pendyala
    @lpendyala_gitlab
    It's not throwing any error and at the same time it's not getting evaluated at all
    Federico Olivieri
    @Federico87_gitlab
    Hi people, I am super new in jmespath. I had just a look to the docs for pyhon and I did not have chance to play with it yet. Just a very high level question. Is there any way to make search to work in the opposite way? I mean, instead to search a key:value, to exclude the key:value passed and return all the rest
    Thank you very much!
    James Saryerwinnie
    @jamesls
    No, not right now :(. I know people want that feature though.
    Federico Olivieri
    @Federico87_gitlab
    If I have something like this : {"peers": {"ns1.sys.cloudsys.tmcs": {"delay": [ 0.476, 0.371 ]}, "insert": { "10.75.33.5": { "delay": [ 0.384 ]}}, "delete": {"ns2.sys.cloudsys.tmcs": { "delay": [ 0.465 ]}}}
    and i want take just insert and delete, is it possible to do with wildcards? kind of peer.[insert|delete] ?
    James Saryerwinnie
    @jamesls
    Federico Olivieri
    @Federico87_gitlab
    Yeap! Amazing! Thanks a lot. I will go tomorrow through all docs. Great application btw!
    mtndoe
    @mtndoe
    Hi people, just learning jmespath. Based on my first experiments I can use jmespath as a template language (meaning using the desired json as a template and using the path expressions to get the necessary values). Using it as such would it be possible to create an object depending on a condition? So if the condition is true create object A else object B or nothing?
    James Saryerwinnie
    @jamesls
    Not really, but conditionals like that is something I'm looking to add.
    Federico Olivieri
    @Federico87_gitlab
    Question. I have a json like the belo and I want to catch just interfaceStatus I can do interfaces.*.interfaceStatus and I get the right result, however I lose Ethernet47 so I am not sure to which interface the interfaceStatus belongs to
    "Ethernet48": {
                "lastStatusChangeTimestamp": [
                    1580496491.6286151,
                    1580496491.6286182
                ]
            },
            "Ethernet47": {
                "lastStatusChangeTimestamp": [
                    1580496491.629291,
                    1582706128.6775026
                ],
                "interfaceStatus": [
                    "connected",
                    "disabled"
                ]
            }
    I can workaround with some code but I was wondering if there is some sort of reference/dereference that I can apply to .*. and get back the value of * where jmspath match
    Chris Armstrong
    @chris-armstrong
    JMESPath doesn't have a way to do this I'm afraid - there are no backreferences to a previous match, nor can you convert the object to a set entries (like JavaScript Object.entries()) and map over the result.
    Chris Armstrong
    @chris-armstrong
    Adding an entries function is a good target for a specification addition, but there is no formal process for those at the moment (development on the main repo seems to be stalled)
    Matthew Slowe
    @jiscfoo
    Afternoon. I am wondering if there are jmespath packages for Alpine Linux…?
    James Saryerwinnie
    @jamesls
    @chris-armstrong I'm thinking it might be helpful to create a new repo that's just for proposing new functionality. Right now there's not really a good way to do that.
    Chris Armstrong
    @chris-armstrong

    There is an official repo (the web site / test suite ones), but I'm not the maintainer (who hasn't responded to some issues for several years), so I don't know who should take responsibility.

    FWIW, I've forked the official documentation site (so I can host it with TLS) and the JS implementation for GorillaStack, and I'm maintaining my own specification additions in the doc site and the JS implementation.

    See:
    https://github.com/gorillastack/jmespath.js
    https://github.com/gorillastack/jmespath.site

    I should probably fork the test suite and get my additions added to it so that others can add my changes if no-one else is going to maintain the site and test suite.
    Really I just need another major language (probably python) and it should be enough for a decent fork.
    Although I'm not completely sold on the syntax for jmespath, it still is being used in major tooling (like aws-cli) and there is plenty of useful, small language additions that could be made without bloating it out of control.
    Chris Armstrong
    @chris-armstrong
    Chris Armstrong
    @chris-armstrong
    I've also forked the jmespath.test repository, upgraded its test infrastructure and schema, and added the compliance tests for GorillaStack's spec additions (split() function and to_json()/parse_json() proposals (both in our jmespath.js fork)
    https://github.com/GorillaStack/jmespath.test
    (see https://gorillastack-jmespath.netlify.com/proposals for descriptions of those proposals)
    James Saryerwinnie
    @jamesls
    @chris-armstrong I'm the maintainer :(. I'd like to get the project back up and running again.
    James Saryerwinnie
    @jamesls
    I also commented on jmespath/jmespath#65 as well, but I'm very interested in hearing everyone's ideas.
    jdevillard
    @jdevillard
    @jamesls 👍
    Chris Armstrong
    @chris-armstrong
    Thanks @jamesls . I'll make sure to at least get the test cases and proposal writeups for split() and to_json()/parse_json() submitted as PRs soon so they can go into the mainline at some point.
    VF-mbrauer
    @VF-mbrauer
    Somebody who can help me to find a way to have a default value if the value inside the JSON is not there?
    This is my filter:
    contains(roles[], 'admin') && 'Admin' || contains(roles[], 'editor') && 'Editor' || 'Viewer'
    This is the error if element is missing:
    t=2020-03-25T12:30:39+0000 lvl=eror msg="Failed to search user info JSON response with provided path" logger=oauth.generic_oauth attributePath="contains(roles[], 'Admin') && 'Admin' || contains(roles[], 'Editor') && 'Editor' || 'Viewer'" err="Invalid type for: <nil>, expected: []jmespath.jpType{\"array\", \"string\"}"
    Jakub
    @jakubgs
    how does one combine strings ?
    i'm trying locations[].{ x: name+'x' }
    how can I add a string to string?
    or even better, how can I do this: locations[].{ x: name+state } ?
    I've been staring at the docs for a good while and I can't seem to be able to find string operations
    am I blind or does this tool just not support string operations?
    or is there string formatting?
    like locations[].{ x: 'prefix ${name} sufix' } ?
    how can I do that?
    Chris Armstrong
    @chris-armstrong
    You may need to work around the lack of string concatenation with the join() function.
    Jakub
    @jakubgs
    ugh
    I need to stop using ansible, such trash
    hack on top of a hack
    freaking regex_replace to append a suffix to a list
    christ on a bike
    thanks for telling me
    the docs for this tool should have a big banner at the top stating "we don't support string operations, leave"
    gg