Skip to content

Custom API Template: .JSON.Array fails to access array directly under top-level key using path #597

Answered by svilenmarkov
kassyss asked this question in Help
Discussion options

You must be logged in to vote

Hey, to access a top-level value or the value of the current context, use an empty string as the key:

{{ range .JSON.Array "" }}

This is documented here. I know it's not the most intuitive thing at first, but I didn't want to introduce a separate function just for this case.

I think I may have misunderstood the issue initially. I tried replicating with the data and template you provided, but it's working as expected:

It looks broken since you've specified data-collapse-after="0", but if you change it to 5 for example and remove the comments, you get what you expect:

Can you add the following to your template to verify that you're getting the expected response?

{{ .Response.StatusCode }}…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@kassyss
Comment options

Answer selected by kassyss
Comment options

You must be logged in to vote
1 reply
@svilenmarkov
Comment options

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