Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    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
    Nathan Winder
    @nathanwinder
    Are there any good examples of non-destructive transforms. I'd like to transform a document retaining its exact structure but adding a property based on the value of another property. A lot of the examples I see result in a subset of the document or transform it from a map to an array etc.
    George Verghese
    @geverghe

    Hey All

    I have the following json snippet:
    [
    {
    "fields": {
    "org.priority": "high"
    },
    "id": 344,
    "relations": null,
    }
    ]

    I am running into challenges when I am trying to extract org.priority field. I have been testing this using https://jsonpath.curiousconcept.com/ . Could someone tell me the right way to do this fetch?

    Greg Wiley
    @aztecrex

    how do you denormalize in JMESPath. For instance if my structure looks like

    {
      "things": [
        {
          "name": "t1",
          "subs": [
            "a",
            "b",
            "c"
          ]
        },
        {
          "name": "t2",
          "subs": [
            "y",
            "z"
          ]
        },
        {
          "name": "t3",
          "subs": []
        },
        {
          "name": "t4"
        }
      ]
    }

    and the output should be one list item per "subs" item:

    [
      ["t1", "a"],
      ["t1", "b"],
      ["t1", "c"],
      ["t2", "y"],
      ["t2", "z"]
    ]

    Can this be done in JMESPath?

    i don't see how to reference the name once i have a flattened list of subs
    Chris Armstrong
    @chris-armstrong
    @aztecrex try to to map the objects to an array of arrays first then flatten it
    Accendit
    @Accendit

    Hi all, I am trying to get all ids from the following data structure:

    [
        {
            "locations": [
                {
                    "id": "1",
                    "name": "Amsterdam"
                },
                {
                    "id": "2",
                    "name": "Rotterdam"
                }
            ],
            "persons": [
                {
                    "id": "3",
                    "name": "John"
                },
                {
                    "id": "4",
                    "name": "Jake"
                }
            ]
        },
        {
            "locations": [
                {
                    "id": "5",
                    "name": "London"
                },
                {
                    "id": "6",
                    "name": "Hamburg"
                }
            ],
            "persons": [
                {
                    "id": "7",
                    "name": "Foo"
                },
                {
                    "id": "8",
                    "name": "Bar"
                }
            ]
        }
    ]

    Id like the output to be:

    [
        [
            "1",
            "2",
            "3",
            "4"
        ],
        [
            "5",
            "6",
            "7",
            "8"
        ]
    ]

    I'm not sure how to achieve this

    Leslie Wilson
    @LeslieWilson
    hello