Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does jmespath support random selecting? #205

Open
oylbin opened this issue Aug 25, 2020 · 1 comment
Open

Does jmespath support random selecting? #205

oylbin opened this issue Aug 25, 2020 · 1 comment

Comments

@oylbin
Copy link

oylbin commented Aug 25, 2020

example data:

{
    "stores":{
        "s1":{
            "id":"s1",
            "openTime": 1234567890
        },
        "s2":{
            "id":"s2",
            "openTime": 1234567891
        },
        "s3":{
            "id":"s3",
            "openTime": 1234567892
        },
        "s4":{
            "id":"s4",
            "openTime": 1234567893
        }
    }
 }

I can get 'id's with

stores.*.id

I can get first id with

stores.*.id | [0]

Is there any build in function that let me random select an id from 'id's ? something like jinja2 random filter:

stores.*.id | random
@2kjiejie
Copy link

I think you can do something like this:
'stories.*id | [' + str(random.randint(0,3)) +']'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants