JSON – How Deeply Can a JSON Object Be Nested?

javascriptjson

I was watching a video on a website that said json objects can be nested deeply. How far can a JSON object be nested before it will create an error?

Best Answer

There is no theoretical limit to how deep JSON objects can be nested, but there usually is a practical limit based on the decoder being used. For example, PHP's json_decode() has a default limit of 512 levels, though it can be adjusted. Read the documentation for the code using the JSON to determine the max depth.

If your JSON is actually hitting depth limits, you probably need to reconsider how your JSON is structured.