Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    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
    hey um, whats like a good tutorial to learn this stuff
    or a textbook or something
    jdevillard
    @jdevillard
    Hello @LeslieWilson have you already take a look at the site https://jmespath.org ?
    tightly-clutched
    @tightly-clutched
    hey, with the new awscli v2 - has anyone heard of an effort to release a compatible version of jpterm (jmespath-terminal)?
    Rajesh Swarnkar
    @RSwarnkar
    Hi There, I need help with this: jmespath/jmespath.py#200
    Rajesh Swarnkar
    @RSwarnkar
    @Accendit Try this [].[locations[].id,persons[].id][][]
    @Accendit Or try this: [ [].[locations[].id][][], [].[persons[].id][][] ] :)
    Jonas Jarutis
    @jarutis

    Hi, is it possible to include missing values in the projection?

    {
      "a": [
        {"b": None},
        {"b": 2}
      ]
    }

    =>

    [None, 2]

    If I search a[].b I get [2].

    Chris Armstrong
    @chris-armstrong
    what about map(&b, a)
    Jonas Jarutis
    @jarutis
    :+1:
    :bow:
    Accendit
    @Accendit
    @RSwarnkar Awesome thats perfect
    Rajesh Swarnkar
    @RSwarnkar
    I was wondering How matured jmespath is as compared to XML's sister languages (XSLT/XPath/XQuery)? I feel there is general lack of standard on json, it doesn't have similar technologies to query/transform json data.
    I have used xslt in past and its quite easy to get along, however working with json using jmespath is bit quirky though. But given current state of jmespath i was able to establish couple of transforms but again those required another level of processing to get desired transformation.
    Rajesh Swarnkar
    @RSwarnkar
    Also, seems current traversal in json data is only down the structure in one way, there is no way to refer back or traverse up to any relative parent.
    Chris Armstrong
    @chris-armstrong

    @RSwarnkar The XML series of languages have quite a different lineage (committee developed standards) vs JSON (which came organically out of JavaScript), so as you can imagine, JMESPath is very much community developed and evolved as needs emerged.

    It also seems to be serving a dual purpose, both query and transformation, which were addressed formally as separate concerns with XML (think XPath vs XSLT).

    Woldemar XmbIpoB
    @wolkym
    Dear all, is there a search possibility on string containing json? I would like to avoid parsing to dict as JSON is quite big.
    Rajesh Swarnkar
    @RSwarnkar
    @chris-armstrong Perfect! Also, There are many contenders to jmespath viz., jsoniq, jaql etc. But jmespath is backed by AWS. Hope we see more features coming. :)
    Sheik Sena Reddy
    @SheikSena
    Hello all, is there a way append values from the same array and convert the value to the single string.