# Error parsing json

**URL:** <https://discuss.elastic.co/t/error-parsing-json/3646>\
**Category:** Elasticsearch\
**Created:** [December 10, 2010, 1:45am UTC](https://discuss.elastic.co/t/error-parsing-json/3646 "2010-12-10T01:45:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anurag\_Phadke](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@Anurag\_Phadke](https://discuss.elastic.co/u/Anurag_Phadke)\
**Post date:** [December 10, 2010, 1:45am UTC](https://discuss.elastic.co/t/error-parsing-json/3646/1 "2010-12-10T01:45:03Z")

</div>

We are using the REST API to retrieve results from ES, query below:  
curl -XGET 'http://:9200/\_search?' -d '  
{  
"query" : {  
"bool" : {  
"must" : [  
{  
"field" : { "filename" :  
"mozilla-central-linux-debug-1291801653-mochitests-3.gz" }  
}  
]  
}  
}  
}'

resulting json:  
{"\_shards":{"total":21,"successful":21,"failed":0},"hits":{"total":1,"max\_score":5.6323466,"hits":[{"\_index":"logs","\_type":"builds","\_id":"YuvVewVoQMiANL3ZqpyXcA","\_score":5.6323466,  
"\_source" : { "builds" : {"repo": "mozilla-central", "buildtype":  
"debug", "machine": "talos-r3-fed-037", "buildurl":  
"[http://stage.mozilla.org/pub/mozilla.org/firefox/tinderbox-builds/mozilla-central-linux-debug/1291801653/firefox-4.0b8pre.en-US.linux-i686.tar.bz2](http://stage.mozilla.org/pub/mozilla.org/firefox/tinderbox-builds/mozilla-central-linux-debug/1291801653/firefox-4.0b8pre.en-US.linux-i686.tar.bz2)",  
"platform": "linux", "buildid": "20101208014733", "filename":  
"mozilla-central-linux-debug-1291801653-mochitests-3.gz", "revision":  
"269083132500"}" } }}]}}

I tried validating the resulting json @  
[http://jsonformatter.curiousconcept.com/](http://jsonformatter.curiousconcept.com/) and it gave the following  
errors:  
Error:Invalid object closure. [Code 15, Structure 89]  
Error:Invalid Braces. [Code 26, Structure 0]

Ditto when I try to parse it using perl module for JSON....  
Any ideas on what might be happening here? Is the validator wrong or  
something's wrong with ES?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [December 10, 2010, 3:36am UTC](https://discuss.elastic.co/t/error-parsing-json/3646/2 "2010-12-10T03:36:25Z")

</div>

Can you send a sample json that you index? I think that the json that you index is malformed (missing } at the end), and the ES parser is relaxed about that when indexing, but, when it constructs the result, it will fail to be parsed.  
On Friday, December 10, 2010 at 3:45 AM, Anurag wrote:

> We are using the REST API to retrieve results from ES, query below:  
> curl -XGET 'http://:9200/\_search?' -d '  
> {  
> "query" : {  
> "bool" : {  
> "must" : [  
> {  
> "field" : { "filename" :  
> "mozilla-central-linux-debug-1291801653-mochitests-3.gz" }  
> }  
> ]  
> }  
> }  
> }'
> 
> resulting json:  
> {"\_shards":{"total":21,"successful":21,"failed":0},"hits":{"total":1,"max\_score":5.6323466,"hits":[{"\_index":"logs","\_type":"builds","\_id":"YuvVewVoQMiANL3ZqpyXcA","\_score":5.6323466,  
> "\_source" : { "builds" : {"repo": "mozilla-central", "buildtype":  
> "debug", "machine": "talos-r3-fed-037", "buildurl":  
> "[http://stage.mozilla.org/pub/mozilla.org/firefox/tinderbox-builds/mozilla-central-linux-debug/1291801653/firefox-4.0b8pre.en-US.linux-i686.tar.bz2](http://stage.mozilla.org/pub/mozilla.org/firefox/tinderbox-builds/mozilla-central-linux-debug/1291801653/firefox-4.0b8pre.en-US.linux-i686.tar.bz2)",  
> "platform": "linux", "buildid": "20101208014733", "filename":  
> "mozilla-central-linux-debug-1291801653-mochitests-3.gz", "revision":  
> "269083132500"}" } }}]}}
> 
> I tried validating the resulting json @  
> [http://jsonformatter.curiousconcept.com/](http://jsonformatter.curiousconcept.com/) and it gave the following  
> errors:  
> Error:Invalid object closure. [Code 15, Structure 89]  
> Error:Invalid Braces. [Code 26, Structure 0]
> 
> Ditto when I try to parse it using perl module for JSON....  
> Any ideas on what might be happening here? Is the validator wrong or  
> something's wrong with ES?

---

<div class="post-metadata">

**Author:** ![Anurag\_Phadke](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@Anurag\_Phadke](https://discuss.elastic.co/u/Anurag_Phadke)\
**Post date:** [December 10, 2010, 4:58am UTC](https://discuss.elastic.co/t/error-parsing-json/3646/3 "2010-12-10T04:58:11Z")

</div>

thanks shay - my code contained an additional " }.... fixed and ES  
now works as advertised 🙂

-anurag

On Thu, Dec 9, 2010 at 7:36 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) wrote:

> Can you send a sample json that you index? I think that the json that you  
> index is malformed (missing } at the end), and the ES parser is relaxed  
> about that when indexing, but, when it constructs the result, it will fail  
> to be parsed.
> 
> On Friday, December 10, 2010 at 3:45 AM, Anurag wrote:
> 
> We are using the REST API to retrieve results from ES, query below:  
> curl -XGET 'http://:9200/\_search?' -d '  
> {  
> "query" : {  
> "bool" : {  
> ""must" : [  
> {  
> "field" : { "filename" :  
> "mozilla-central-linux-debug-1291801653-mochitests-3.gz" }  
> }  
> ]  
> }}  
> }  
> }'
> 
> resulting json:  
> {"\_shards":{"total":21,"successful":21,"failed":0},"hits":{"total":1,"max\_score":5.6323466,"hits":[{"\_index":"logs","\_type":"builds","\_id":"YuvVewVoQMiANL3ZqpyXcA","\_score":5.6323466,  
> "\_source" : { "builds" : {"repo": "mozilla-central", "buildtype":  
> "debug", "machine": "talos-r3-fed-037", "buildurl":  
> "[http://stage.mozilla.org/pub/mozilla.org/firefox/tinderbox-builds/mozilla-central-linux-debug/1291801653/firefox-4.0b8pre.en-US.linux-i686.tar.bz2](http://stage.mozilla.org/pub/mozilla.org/firefox/tinderbox-builds/mozilla-central-linux-debug/1291801653/firefox-4.0b8pre.en-US.linux-i686.tar.bz2)",  
> "platform": "linux", "buildid": "20101208014733", "filename":  
> "mozilla-central-linux-debug-1291801653-mochitests-3.gz", "revision":  
> "269083132500"}" } }}]}}
> 
> I tried validating the resulting json @  
> [http://jsonformatter.curiousconcept.com/](http://jsonformatter.curiousconcept.com/) and it gave the following  
> errors:  
> Error:Invalid object closure. [Code 15, Structure 89]  
> Error:Invalid Braces. [Code 26, Structure 0]
> 
> Ditto when I try to parse it using perl module for JSON....  
> Any ideas on what might be happening here? Is the validator wrong or  
> something's wrong with ES?

---

<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:** [July 6, 2017, 4:15am UTC](https://discuss.elastic.co/t/error-parsing-json/3646/4 "2017-07-06T04:15:29Z")

</div>


