# JSON Depth level

**URL:** <https://discuss.elastic.co/t/json-depth-level/66029>\
**Category:** Elasticsearch\
**Created:** [November 14, 2016, 10:01pm UTC](https://discuss.elastic.co/t/json-depth-level/66029 "2016-11-14T22:01:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zfs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zfs/32/13370_2.png) [@Zfs](https://discuss.elastic.co/u/Zfs)\
**Post date:** [November 14, 2016, 10:01pm UTC](https://discuss.elastic.co/t/json-depth-level/66029/1 "2016-11-14T22:01:20Z")

</div>

I was wondering if there's a limit on the depth of a JSON object?

I'm basically taking [http://localhost:9200/\_cluster/stats](http://localhost:9200/_cluster/stats) and reposting this back into elasticsearch.

I'm able to insert up to a depth of 4 but going higher I receive a 400 error.

Thanks

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 14, 2016, 10:09pm UTC](https://discuss.elastic.co/t/json-depth-level/66029/2 "2016-11-14T22:09:07Z")

</div>

What is the actual error you are getting.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 15, 2016, 3:14am UTC](https://discuss.elastic.co/t/json-depth-level/66029/3 "2016-11-15T03:14:39Z")

</div>

In 5.0 there is now a limit for the maximum number of fields in a document.

IIRC it's 200.

May it's what you are seeing? As Mark said, what is the error message?

---

<div class="post-metadata">

**Author:** ![Zfs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zfs/32/13370_2.png) [@Zfs](https://discuss.elastic.co/u/Zfs)\
**Post date:** [November 15, 2016, 3:39pm UTC](https://discuss.elastic.co/t/json-depth-level/66029/4 "2016-11-15T15:39:25Z")

</div>

Hi,

I'm running the following from powershell:

```
$a = Invoke-RestMethod -Uri "http://127.0.0.1:9200/_cluster/stats"
$json = $a | convertTo-json -Depth 5
Invoke-RestMethod "http://monitoring_cluster:9200/test_index/message" -Method Post -Body $json -ContentType 'application/json'

```

Fails with:

```
Message : {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse [indices.shards.index]"}],"type":"mapper_parsing_exception","reason":"failed to parse
                          [indices.shards.index]","caused_by":{"type":"illegal_argument_exception","reason":"unknown property [shards]"}},"status":400}

```

If I adjust the Depth to 2 it submits fine, but it chops off tags.

---

<div class="post-metadata">

**Author:** ![Zfs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zfs/32/13370_2.png) [@Zfs](https://discuss.elastic.co/u/Zfs)\
**Post date:** [November 15, 2016, 5:17pm UTC](https://discuss.elastic.co/t/json-depth-level/66029/5 "2016-11-15T17:17:52Z")

</div>

Oddly enough, I saved the $json as a file and loaded it with curl and that worked fine.

```
curl -XPOST 'http://xx.xx.xx.xx:9200/test/test' -d @test.json
{"_index":"test","_type":"test","_id":"AVho9cHiIEEqlD75Hi_Z","_version":1,"_shards":{"total":2,"successful":2,"failed":0}

```

It seems the only error in Kibana would be that "Objects in Arrays are not well supported"

```
 nodes.jvm.versions {
                                                     "version": "1.8.0_102",
                                                     "vm_name": "Java HotSpot(TM) 64-Bit Server VM",
                                                     "vm_version": "25.102-b14", 
                                                     "vm_vendor": "Oracle Corporation",
                                                     "count": 12
                                                     }

```

I'll have to see why powershell would complain.

---

<div class="post-metadata">

**Author:** ![Zfs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zfs/32/13370_2.png) [@Zfs](https://discuss.elastic.co/u/Zfs)\
**Post date:** [November 15, 2016, 8:21pm UTC](https://discuss.elastic.co/t/json-depth-level/66029/6 "2016-11-15T20:21:31Z")

</div>

Removed the index and started fresh. No errors from powershell this time.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 13, 2016, 8:21pm UTC](https://discuss.elastic.co/t/json-depth-level/66029/7 "2016-12-13T20:21:48Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
