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

--expect-body-json comparison with value #203

Open
lzecca78 opened this issue Nov 10, 2023 · 1 comment
Open

--expect-body-json comparison with value #203

lzecca78 opened this issue Nov 10, 2023 · 1 comment

Comments

@lzecca78
Copy link

Hi, i am using wait4x in the pipeline using the HTTP provider in order to compare a specific body JSON key with a specific value. AFAIK, also looking at the gjson doc, this seems not possible.
For example a body with

{"version": 1234} 

cannot be done afaik with --expect-body-json with something like:

wait4x http https://ifconfig.co/json --expect-body-json "version==1234" or something similar.

@mortymacs
Copy link
Collaborator

Hi,

Unfortunately, at the moment, we and gjson only check the existence of keys therefore you can use --expect-body-regex instead:

$ wait4x http https://ifconfig.co/json --expect-body-regex '"version": "1234"'

The "condition" only works in the array based on the gjson documentation https://github.com/tidwall/gjson

@atkrad suggested to use https://github.com/antonmedv/expr to handle complex expressions. Maybe in the future, we'll support it. @lzecca78 you can send a PR if you would like to contribute.

If you have any ideas, we would be happy to hear them to fix the issue fundamentally.

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