# JSON not well formed?

**URL:** <https://discuss.elastic.co/t/json-not-well-formed/2875>\
**Category:** Elasticsearch\
**Created:** [March 28, 2010, 2:00pm UTC](https://discuss.elastic.co/t/json-not-well-formed/2875 "2010-03-28T14:00:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![timrobertson100](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timrobertson100/32/2467_2.png) [@timrobertson100](https://discuss.elastic.co/u/timrobertson100)\
**Post date:** [March 28, 2010, 2:00pm UTC](https://discuss.elastic.co/t/json-not-well-formed/2875/1 "2010-03-28T14:00:30Z")

</div>

I am trying to use JQuery to issue an ajaxy request to ES, but it  
fails. JQuery docs tell me it will 'fail silently' if the JSON is not  
well formed, and in firefox, the JSONView plugin is indeed telling me  
that the example [http://localhost:9200/twitter/user/kimchy?pretty=true](http://localhost:9200/twitter/user/kimchy?pretty=true)  
is not well formed. It returns:

{  
"\_index" : "twitter",  
"\_type" : "user",  
"\_id" : "kimchy", "\_source" :  
{ name: "Shay Banon" }  
}

If I change manually the JSON, so that the name becomes "name" it  
seems to work fine in

Is this a bug or a desired feature or maybe the legacy of a JSON serializer?

Cheers,  
Tim

---

<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:** [March 28, 2010, 2:17pm UTC](https://discuss.elastic.co/t/json-not-well-formed/2875/2 "2010-03-28T14:17:24Z")

</div>

The \_source field is the actual JSON document that you indexed. So, if you  
indexed it without quotes on field names, it will be returned without  
quotes. This is partially my fault, since in some of the examples I don't  
quote field names, I need to change all the samples to index quoted JSON  
field names.

In terms of elasticsearch, it can parse both quoted and unquoted field  
names.

-shay.banon

On Sun, Mar 28, 2010 at 5:00 PM, Tim Robertson [timrobertson100@gmail.com](mailto:timrobertson100@gmail.com)wrote:

> I am trying to use JQuery to issue an ajaxy request to ES, but it  
> fails. JQuery docs tell me it will 'fail silently' if the JSON is not  
> well formed, and in firefox, the JSONView plugin is indeed telling me  
> that the example [http://localhost:9200/twitter/user/kimchy?pretty=true](http://localhost:9200/twitter/user/kimchy?pretty=true)  
> is not well formed. It returns:
> 
> {  
> "\_index" : "twitter",  
> "\_type" : "user",  
> "\_id" : "kimchy", "\_source" :  
> { name: "Shay Banon" }  
> }
> 
> If I change manually the JSON, so that the name becomes "name" it  
> seems to work fine in
> 
> Is this a bug or a desired feature or maybe the legacy of a JSON  
> serializer?
> 
> Cheers,  
> Tim

---

<div class="post-metadata">

**Author:** ![timrobertson100](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timrobertson100/32/2467_2.png) [@timrobertson100](https://discuss.elastic.co/u/timrobertson100)\
**Post date:** [March 28, 2010, 2:29pm UTC](https://discuss.elastic.co/t/json-not-well-formed/2875/3 "2010-03-28T14:29:07Z")

</div>

Thanks Shay,

When I use quotes on insert it all runs just fine.

On Sun, Mar 28, 2010 at 4:17 PM, Shay Banon  
[shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) wrote:

> The \_source field is the actual JSON document that you indexed. So, if you  
> indexed it without quotes on field names, it will be returned without  
> quotes. This is partially my fault, since in some of the examples I don't  
> quote field names, I need to change all the samples to index quoted JSON  
> field names.  
> In terms of elasticsearch, it can parse both quoted and unquoted field  
> names.  
> -shay.banon
> 
> On Sun, Mar 28, 2010 at 5:00 PM, Tim Robertson [timrobertson100@gmail.com](mailto:timrobertson100@gmail.com)  
> wrote:
> 
> > I am trying to use JQuery to issue an ajaxy request to ES, but it  
> > fails. JQuery docs tell me it will 'fail silently' if the JSON is not  
> > well formed, and in firefox, the JSONView plugin is indeed telling me  
> > that the example [http://localhost:9200/twitter/user/kimchy?pretty=true](http://localhost:9200/twitter/user/kimchy?pretty=true)  
> > is not well formed. It returns:
> > 
> > {  
> > "\_index" : "twitter",  
> > "\_type" : "user",  
> > "\_id" : "kimchy", "\_source" :  
> > { name: "Shay Banon" }  
> > }
> > 
> > If I change manually the JSON, so that the name becomes "name" it  
> > seems to work fine in
> > 
> > Is this a bug or a desired feature or maybe the legacy of a JSON  
> > serializer?
> > 
> > Cheers,  
> > Tim

---

<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:25am UTC](https://discuss.elastic.co/t/json-not-well-formed/2875/4 "2017-07-06T04:25:02Z")

</div>


