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

Assertion Fails on JSON field with invalid character (hyphen) #2474

Open
2 tasks done
fgrande opened this issue Jun 17, 2024 · 3 comments
Open
2 tasks done

Assertion Fails on JSON field with invalid character (hyphen) #2474

fgrande opened this issue Jun 17, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@fgrande
Copy link
Contributor

fgrande commented Jun 17, 2024

I have checked the following:

  • I use the newest version of bruno.
  • I've searched existing issues and found nothing related to my issue.

Describe the bug

Asserting a field that contains an hyphen in its name result in an error.
For instance, in the associated bru file, the assert

res.body.life-span.begin: eq "1989"

result in a problem, since "life-span" is not a valid js fieldname

Trying to attach a PR that would solve the issue

.bru file to reproduce the bug

MusicBrainz JSON.bru.zip

Screenshots/Live demo link

image
@fgrande fgrande added the bug Something isn't working label Jun 17, 2024
@fgrande
Copy link
Contributor Author

fgrande commented Jun 17, 2024

PR #2475

@fgrande fgrande changed the title Assertion on JSON field with invalid character (hyphen) Assertion Fails on JSON field with invalid character (hyphen) Jun 17, 2024
@lohxt1
Copy link
Collaborator

lohxt1 commented Jun 18, 2024

writing the expression like below should work

res.body?.['life-span']?.begin

@fgrande
Copy link
Contributor Author

fgrande commented Jun 18, 2024

@lohxt1 I confirm it works, thanks a lot for the hint. Actually it works also as "res.body['life-span'].begin"
Anyway, wouldn't it be nice to write it in a simpler way ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants