# Json

**URL:** <https://discuss.elastic.co/t/json/2810>\
**Category:** Elasticsearch\
**Created:** [February 14, 2010, 6:16pm UTC](https://discuss.elastic.co/t/json/2810 "2010-02-14T18:16:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [February 14, 2010, 6:16pm UTC](https://discuss.elastic.co/t/json/2810/1 "2010-02-14T18:16:44Z")

</div>

Hiya

I like the look of ElasticSearch, and am planning on using it on our  
website, assuming my testing works out.

I'm writing a Perl wrapper around it, and one issue I've come across  
is that the JSON it returns is not strictly correct. According to the  
JSON specs ([http://www.json.org/](http://www.json.org/)), property names should be quoted,  
eg:

Correct: { "foo": "bar"}  
Incorrect: { foo: "bar"}

The fastest and safest JSON parser available for Perl only accepts  
valid JSON, so it'd be great for us to get this corrected.

thanks

Clint

---

<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:** [February 14, 2010, 6:30pm UTC](https://discuss.elastic.co/t/json/2810/2 "2010-02-14T18:30:54Z")

</div>

Hey,

elasticsearch returns valid JSON in all of its APIs. The only place where  
there is no JSON formatting is on the source JSON you used to index. If the  
JSON you used to index the data does not have quotes, then it will be  
returned without quotes. Maybe thats what you are seeing? If not, then can  
you post which API does not have a valid JSON?

p.s. I use a "non valid" JSON in the samples since it makes them more  
readable, but elasticsearch will also parse valid JSON of course ;).

-shay.banon

On Sun, Feb 14, 2010 at 8:16 PM, Clinton [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk) wrote:

> Hiya
> 
> I like the look of Elasticsearch, and am planning on using it on our  
> website, assuming my testing works out.
> 
> I'm writing a Perl wrapper around it, and one issue I've come across  
> is that the JSON it returns is not strictly correct. According to the  
> JSON specs ([http://www.json.org/](http://www.json.org/)), property names should be quoted,  
> eg:
> 
> Correct: { "foo": "bar"}  
> Incorrect: { foo: "bar"}
> 
> The fastest and safest JSON parser available for Perl only accepts  
> valid JSON, so it'd be great for us to get this corrected.
> 
> thanks
> 
> Clint

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [February 14, 2010, 6:42pm UTC](https://discuss.elastic.co/t/json/2810/3 "2010-02-14T18:42:34Z")

</div>

> I'm writing a Perl wrapper around it, and one issue I've come across  
> is that the JSON it returns is not strictly correct.

Actually, there seems to be a bug in the JSON handling. It seems that  
you accept invalid data (eg with unquoted property names), store it as a  
string, but then you return that string as though it were valid JSON.

Compare:

1. VALID JSON IN -\> VALID JSON OUT

> curl -XPUT [http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1) -d '  
> {  
> "user" : "kimchy"  
> }  
> '

* * *

{"ok":true,"\_index":"twitter","\_type":"tweet","\_id":"1"}

ï»¿\> curl -XGET [http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)  
ï»¿----------------------------------------------------------  
{"\_index":"twitter","\_type":"tweet","\_id":"1", "\_source" :  
{  
"user" : "kimchy"  
}  
}

ï»¿2) INVALID JSON IN -\> INVALID JSON OUT

> curl -XPUT [http://localhost:9200/twitter/tweet/2](http://localhost:9200/twitter/tweet/2) -d '  
> {  
> user : "kimchy"  
> }  
> '  
> ï»¿----------------------------------------------------------  
> {"ok":true,"\_index":"twitter","\_type":"tweet","\_id":"2"}

> curl -XGET [http://localhost:9200/twitter/tweet/2](http://localhost:9200/twitter/tweet/2)  
> ï»¿----------------------------------------------------------  
> {"\_index":"twitter","\_type":"tweet","\_id":"2", "\_source" :  
> {  
> user : "kimchy"  
> }  
> }

clint

--  
Web Announcements Limited is a company registered in England and Wales,  
with company number 05608868, with registered address at 10 Arvon Road,  
London, N5 1PR.

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [February 14, 2010, 6:44pm UTC](https://discuss.elastic.co/t/json/2810/4 "2010-02-14T18:44:54Z")

</div>

> elasticsearch returns valid JSON in all of its APIs. The only place  
> where there is no JSON formatting is on the source JSON you used to  
> index. If the JSON you used to index the data does not have quotes,  
> then it will be returned without quotes. Maybe thats what you are  
> seeing? If not, then can you post which API does not have a valid  
> JSON?

It seems our posts crossed in the ether 🙂

clint

---

<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:** [February 14, 2010, 6:46pm UTC](https://discuss.elastic.co/t/json/2810/5 "2010-02-14T18:46:23Z")

</div>

Maybe in the future Google Wave will come to the rescue :).

On Sun, Feb 14, 2010 at 8:44 PM, Clinton Gormley [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk)wrote:

> > elasticsearch returns valid JSON in all of its APIs. The only place  
> > where there is no JSON formatting is on the source JSON you used to  
> > index. If the JSON you used to index the data does not have quotes,  
> > then it will be returned without quotes. Maybe thats what you are  
> > seeing? If not, then can you post which API does not have a valid  
> > JSON?
> 
> It seems our posts crossed in the ether 🙂
> 
> clint

---

<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/2810/6 "2017-07-06T04:25:46Z")

</div>


