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

Fix ParseJsonHelper not storing parsed result in variable (if any) when json is empty #2277

Conversation

G-Basak
Copy link
Contributor

@G-Basak G-Basak commented Jul 17, 2023

Parse-Json-Helper for Handlebars should store the parsed json in variable specified and should evaluate to empty string for that section.

For example :

{{#parseJson 'parsedObj'}}
{"key":"value"}
{{/parseJson}}
{{#assign 'json'}}
{"key":"value"}
{{/assign}}
{{parseJson json 'parsedObj'}}

In both scenario, it will parse and store the json {"key":"value"} to a variable named parsedObj, and evaluate to an empty string for that section.

However, this was not happening when that inner-json was empty like below. Nothing was being stored in the variable, and the section was being evaluated to {}

{{#parseJson 'parsedObj'}}
{}
{{/parseJson}}
{{#assign 'json'}}
{}
{{/assign}}
{{parseJson json 'parsedObj'}}

References

closes #2085

Submitter checklist

  • The PR request is well described and justified, including the body and the references
  • The PR title represents the desired changelog entry
  • The repository's code style is followed (see the contributing guide)
  • Test coverage that demonstrates that the change works as expected
  • For new features, there's necessary documentation in this pull request or in a subsequent PR to wiremock.org

@G-Basak G-Basak marked this pull request as ready for review July 17, 2023 22:12
@G-Basak G-Basak requested a review from a team as a code owner July 17, 2023 22:12
Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch!

@oleg-nenashev oleg-nenashev merged commit 66f10f3 into wiremock:master Jul 19, 2023
7 checks passed
@G-Basak G-Basak deleted the fix-ParseJson-not-storing-result-for-empty-json branch July 19, 2023 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Result (emptyJson) returned immediately without being stored in a variable, if any
3 participants