JSON

JSON_DEPTH

MySQLMySQL

Mengembalikan kedalaman maksimum JSON document. Empty array/object = 1, scalar = 1, nested structures menambah depth.

Tipe hasil: INTDiperbarui: 7 Jan 2026

Syntax

SQL
JSON_DEPTH(json_doc)

Parameter

json_docJSONwajib

JSON document

Contoh Penggunaan

Simple Array Depth

SQL
1SELECT JSON_DEPTH('[1, 2, 3]') AS depth;

Array sederhana tanpa nesting.

Hasil
depth: 2

Nested Object Depth

SQL
1SELECT JSON_DEPTH('{"a": {"b": {"c": 1}}}') AS depth;

Object dengan 3 level nesting.

Hasil
depth: 4

Find Deep JSON

SQL
1SELECT id, JSON_DEPTH(data) AS depth
2FROM json_table
3WHERE JSON_DEPTH(data) > 5;

Mencari JSON dengan nesting dalam.

Hasil
(deeply nested JSON rows)