by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Jason Slagle
    @jmslagle
    Is JEP-11 dead?
    Jens J.
    @zerog2k

    I feel really dumb, but can't seem to figure out how to transform this:

    {
        "Foo": "somekey",
        "Bar": "somevalue"
    }

    into:

    { "somekey": "somevalue" }

    the closest I can get is like:

    { Foo : Bar }

    but that yields:

    {
      "Foo": "somevalue"
    }

    so it's the key in the hash part I cant figure out how to get
    (I want to make the new hash's key, the value of an existing key in the input hash)

    Jens J.
    @zerog2k

    so I have read somewhere this may not be possible w/ stock JMESPath

    Jmespath does not allow to use dynamic names in multi select hashes.

    but there is some extension:
    https://github.com/grofers/go-codon/wiki/Jmespath-extensions#5-support-for--expressions-as-key-when-performing-multi-select-hash
    (wanted to be able to do this in aws cli --query )

    Jens J.
    @zerog2k
    i guess i need to pass output through jq from_entries
    aws ec2 describe-tags --filters "Name=resource-id,Values=${INSTANCE_ID}" --query 'Tags' | jq from_entries >/tmp/tags.json
    basically gives me what I want ;)
    wu-lee
    @wu-lee
    Is there a way to turn an object of objects into a list of {key1, key2, value} objects?
    For example: {animal: {ant: 1, bee: 2, cat: 3}, vegetable: {apple: 4, banana: 5}, mineral: {axe: 6, bell; 7}} into [{key1: "animal", key2: "ant", value: }, {key1: "animal", key2: "bee", value: 2}, ... {key1: "mineral", key2: "bell", value: 7}]
    wu-lee
    @wu-lee
    Or even just doing it for a single object?
    dr7tbien
    @dr7tbien
    ¿?
    Hi
    dr7tbien
    @dr7tbien
    I'm trying install aws sdk php v3. And I've got this:
    composer require aws/aws-sdk-php
    Using version ^3.133 for aws/aws-sdk-php
    ./composer.json has been created
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
    Your requirements could not be resolved to an installable set of packages.
    
      Problem 1
        - Installation request for mtdowling/jmespath.php (installed at 2.4.0) -> satisfiable by mtdowling/jmespath.php[2.4.0].
        - aws/aws-sdk-php 3.133.0 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
        - aws/aws-sdk-php 3.133.1 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
        - aws/aws-sdk-php 3.133.10 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
        - aws/aws-sdk-php 3.133.11 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
        - aws/aws-sdk-php 3.133.2 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
        - aws/aws-sdk-php 3.133.3 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
        - aws/aws-sdk-php 3.133.4 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
        - aws/aws-sdk-php 3.133.5 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
        - aws/aws-sdk-php 3.133.6 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
        - aws/aws-sdk-php 3.133.7 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
        - aws/aws-sdk-php 3.133.8 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
        - aws/aws-sdk-php 3.133.9 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
        - Conclusion: don't install mtdowling/jmespath.php 2.5.0
        - Installation request for aws/aws-sdk-php ^3.133 -> satisfiable by aws/aws-sdk-php[3.133.0, 3.133.1, 3.133.10, 3.133.11, 3.133.2, 3.133.3, 3.133.4, 3.133.5, 3.133.6, 3.133.7, 3.133.8, 3.133.9].
    
    
    Installation failed, deleting ./composer.json.
    The issue is that ubuntu only can get V2.3 by apt-get
    how I could install the V2.5?
    Doqnach
    @Doqnach
    how do you mean apt-get?
    this says composer @dr7tbien
    try composer why --tree mtdowling/jmespath to see why it is locked to 2.4.0
    Andrew Curioso
    @andrewcurioso
    Hello all... is there a way to emulate a ternary operator? Basically I want one value is there is a match and another value if there isn't
    Never mind, this works
    locations[0].state == 'NY' && 'a' || 'b'
    lakshmi Pendyala
    @lpendyala_gitlab
    Hi Everyone, new to jmespath and yaml. So I've a requirement where I'm substituting region as a variable, I'm getting this error. jmespath.exceptions.LexerError: Bad jmespath expression: Unknown token '-':
    "123456789012".us-east-1 . Any help would be appreciable.
    this is my original yaml file expression expr: '"{account_id}".{region}'
    James Saryerwinnie
    @jamesls
    You need to quote values that have chars that aren't a-zA-Z0-9
    try "{account_id}"."{region}"
    lakshmi Pendyala
    @lpendyala_gitlab
    expected <block end>, but found '<scalar>'
    in "<unicode string>", line 18, column 31:
    expr: "{account_id}"."{region}"
    James Saryerwinnie
    @jamesls
    I don't think that's a jmespath error? Here's a full example:
    $ echo '{"12345": {"us-east-1": "value-i-want"}}' | jp.py '"12345"."us-east-1"'
    "value-i-want"
    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.