View My JSON
Skip to main content
Blog

How to view nested JSON clearly (and read it safely in code)

Make sense of deeply nested JSON: trace a value through its parents, expand only one branch, and access it safely with optional chaining or jq paths.

Real JSON is rarely flat. A response from a payment provider, a cloud API or a CMS often has objects inside arrays inside objects, five or six levels deep, and the value you want is buried somewhere in the middle. Reading it as a wall of indented text is slow and error-prone. This post covers two connected skills: reading a nested document without getting lost, and writing code that reaches into it without throwing an error when a branch is missing. The examples use one invoice payload throughout, so you can see the same path from three angles.

Sources and further reading

Try the JSON workspace