JSON not well formed?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

JSON not well formed?

timrobertson100
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
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
Reply | Threaded
Open this post in threaded view
|

Re: JSON not well formed?

kimchy
Administrator
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 <[hidden email]> 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
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

Reply | Threaded
Open this post in threaded view
|

Re: JSON not well formed?

timrobertson100
Thanks Shay,

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



On Sun, Mar 28, 2010 at 4:17 PM, Shay Banon
<[hidden email]> 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 <[hidden email]>
> 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
>> 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
>
>