Orange-OpenSource / hurl

Hurl, run and test HTTP requests with plain text.
https://hurl.dev
Apache License 2.0
12.27k stars 476 forks source link

Can you output certain fields in JSON format to output? #2983

Open baerwang opened 1 week ago

baerwang commented 1 week ago

Problem to solve

Create tokens and deliver them to different hurl dependencies

get token

GET {{host}}/v1/integration/register
[Options]
output: integration_output
HTTP 200
[Captures]
token: jsonpath "$.result.token"

api response

{"token":"secret"}

integration_output file

token: secret

use hurl command execute next.hurl

hurl --test --error-format long --variables-file integration_output next.hurl

next.hurl

GET {{host}}/v1/integration
Authorization: Bearer {{access_token}}
HTTP 200

Proposal

Additional context and resources

Tasks to complete

jcamiel commented 1 week ago

Hi @baerwang

Would it be possible to use --jsonoption and piping the output with jq for instance to extract captured variables? I have the impression that it could address your needs.

baerwang commented 1 week ago

Hi @baerwang

Would it be possible to use --jsonoption and piping the output with jq for instance to extract captured variables? I have the impression that it could address your needs.

I think hurl could consider adding json parse,jq reduces development efficiency