# ES JsonParseException

**URL:** <https://discuss.elastic.co/t/es-jsonparseexception/19853>\
**Category:** Elasticsearch\
**Created:** [September 18, 2014, 1:25am UTC](https://discuss.elastic.co/t/es-jsonparseexception/19853 "2014-09-18T01:25:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Foobar\_Geez](https://avatars.discourse-cdn.com/v4/letter/f/ecccb3/32.png) [@Foobar\_Geez](https://discuss.elastic.co/u/Foobar_Geez)\
**Post date:** [September 18, 2014, 1:25am UTC](https://discuss.elastic.co/t/es-jsonparseexception/19853/1 "2014-09-18T01:25:49Z")

</div>

Hello,  
I am a newbie to ES and would appreciate any insights into the below issue  
(going crazy for the last couple of hours :/):

I need to store the following string value into a field -- foo\bar -- with  
the literal backslash in it.

curl -XPUT '[http://localhost:9200/test/test/test](http://localhost:9200/test/test/test)' -d '  
{  
"rules": [  
{  
"users" : ["foo\bar"]  
]  
}'

I get the following error:

{"error":"RemoteTransportException[[High-Tech][inet[/X.X.X.X:9300]][index]];  
nested: MapperParsingException[failed to parse [rules.users]]; nested:  
JsonParseException[Unrecognized character escape 'k' (code 107)\n at  
[Source: UNKNOWN; line: 10, column: 42]]; ","status":400}

I tried "foo\bar" and the value gets stored as "foo\bar".

Any ideas on how to store "foo\bar" with the literal backslash in it?

Thanks in advance!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1f4a3fb8-6835-4851-a354-acd5fa8f97bb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1f4a3fb8-6835-4851-a354-acd5fa8f97bb%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineeth_mohan_2/32/747_2.png) [@vineeth\_mohan\_2](https://discuss.elastic.co/u/vineeth_mohan_2)\
**Post date:** [September 18, 2014, 6:02am UTC](https://discuss.elastic.co/t/es-jsonparseexception/19853/2 "2014-09-18T06:02:01Z")

</div>

Hello ,

This don't have to do anything with the escape character -  
Try below -

curl -XPUT '[http://localhost:9200/test/test/test](http://localhost:9200/test/test/test)' -d '  
{  
"rules": [  
{  
"users" : ["foo\bar"]  
}  
]  
}'

Thanks  
Vineeth

On Thu, Sep 18, 2014 at 6:55 AM, Foobar Geez [foobargeez@gmail.com](mailto:foobargeez@gmail.com) wrote:

> Hello,  
> I am a newbie to ES and would appreciate any insights into the below issue  
> (going crazy for the last couple of hours :/):
> 
> I need to store the following string value into a field -- foo\bar -- with  
> the literal backslash in it.
> 
> curl -XPUT '[http://localhost:9200/test/test/test](http://localhost:9200/test/test/test)' -d '  
> {  
> "rules": [  
> {  
> "users" : ["foo\bar"]  
> ]  
> }'
> 
> I get the following error:
> 
> {"error":"RemoteTransportException[[High-Tech][inet[/X.X.X.X:9300]][index]];  
> nested: MapperParsingException[failed to parse [rules.users]]; nested:  
> JsonParseException[Unrecognized character escape 'k' (code 107)\n at  
> [Source: UNKNOWN; line: 10, column: 42]]; ","status":400}
> 
> I tried "foo\bar" and the value gets stored as "foo\bar".
> 
> Any ideas on how to store "foo\bar" with the literal backslash in it?
> 
> Thanks in advance!
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/1f4a3fb8-6835-4851-a354-acd5fa8f97bb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1f4a3fb8-6835-4851-a354-acd5fa8f97bb%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/1f4a3fb8-6835-4851-a354-acd5fa8f97bb%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/1f4a3fb8-6835-4851-a354-acd5fa8f97bb%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGdPd5kudnsHv-RrjLhpAVvXufUREVqKPZhn7shfzdxBm9sEEQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5kudnsHv-RrjLhpAVvXufUREVqKPZhn7shfzdxBm9sEEQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Foobar\_Geez](https://avatars.discourse-cdn.com/v4/letter/f/ecccb3/32.png) [@Foobar\_Geez](https://discuss.elastic.co/u/Foobar_Geez)\
**Post date:** [September 18, 2014, 10:40am UTC](https://discuss.elastic.co/t/es-jsonparseexception/19853/3 "2014-09-18T10:40:48Z")

</div>

Thanks. I provided a bad example as I guess I over-simplified it and also  
edited it to remove proprietary data (thus, missed }).

The following example exhibits the same issue as described in my original  
post.

curl -XPUT '[http://localhost:9200/test/test/test](http://localhost:9200/test/test/test)' -d '  
{  
"rules": [  
{  
"users" : ["mile\kilo"]  
}  
]  
}'  
{"error":"RemoteTransportException[[High-Tech][inet[/X.X.X.X:9300]][index]];  
nested: MapperParsingException[failed to parse [rules.users]]; nested:  
JsonParseException[Unrecognized character escape 'k' (code 107)\n at  
[Source: UNKNOWN; line: 5, column: 40]]; ","status":400}

On Thursday, September 18, 2014 2:02:12 AM UTC-4, vineeth mohan wrote:

> Hello ,
> 
> This don't have to do anything with the escape character -  
> Try below -
> 
> curl -XPUT '[http://localhost:9200/test/test/test](http://localhost:9200/test/test/test)' -d '  
> {  
> "rules": [  
> {  
> "users" : ["foo\bar"]  
> }  
> ]  
> }'
> 
> Thanks  
> Vineeth
> 
> On Thu, Sep 18, 2014 at 6:55 AM, Foobar Geez \<[fooba...@gmail.com](mailto:fooba...@gmail.com)  
> \<javascript:\>\> wrote:
> 
> > Hello,  
> > I am a newbie to ES and would appreciate any insights into the below  
> > issue (going crazy for the last couple of hours :/):
> > 
> > I need to store the following string value into a field -- foo\bar --  
> > with the literal backslash in it.
> > 
> > curl -XPUT '[http://localhost:9200/test/test/test](http://localhost:9200/test/test/test)' -d '  
> > {  
> > "rules": [  
> > {  
> > "users" : ["foo\bar"]  
> > ]  
> > }'
> > 
> > I get the following error:
> > 
> > {"error":"RemoteTransportException[[High-Tech][inet[/X.X.X.X:9300]][index]];  
> > nested: MapperParsingException[failed to parse [rules.users]]; nested:  
> > JsonParseException[Unrecognized character escape 'k' (code 107)\n at  
> > [Source: UNKNOWN; line: 10, column: 42]]; ","status":400}
> > 
> > I tried "foo\bar" and the value gets stored as "foo\bar".
> > 
> > Any ideas on how to store "foo\bar" with the literal backslash in it?
> > 
> > Thanks in advance!
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/1f4a3fb8-6835-4851-a354-acd5fa8f97bb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1f4a3fb8-6835-4851-a354-acd5fa8f97bb%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/1f4a3fb8-6835-4851-a354-acd5fa8f97bb%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/1f4a3fb8-6835-4851-a354-acd5fa8f97bb%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/955bb1e7-9866-4253-8cff-d782b5a34eda%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/955bb1e7-9866-4253-8cff-d782b5a34eda%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 19, 2014, 6:43am UTC](https://discuss.elastic.co/t/es-jsonparseexception/19853/4 "2014-09-19T06:43:49Z")

</div>

On Thursday, September 18, 2014 at 12:40 CEST,  
Foobar Geez [foobargeez@gmail.com](mailto:foobargeez@gmail.com) wrote:

> Thanks. I provided a bad example as I guess I over-simplified it and  
> also edited it to remove proprietary data (thus, missed }).  
> The following example exhibits the same issue as described in my  
> original post.  
> curl -XPUT '[1][http://localhost:9200/test/test/test](http://localhost:9200/test/test/test)' -d '  
> {  
> "rules": [  
> {  
> "users" : ["mile\kilo"]  
> }  
> ]  
> }'  
> {"error":"RemoteTransportException[[High-Tech][inet[/X.X.X.X:9300]][ind  
> ex]]; nested: MapperParsingException[failed to parse [rules.users]];  
> nested: JsonParseException[Unrecognized character escape 'k' (code  
> 107)\n at [Source: UNKNOWN; line: 5, column: 40]]; ","status":400}

As with many other languages, literal backslashes in string literals  
need to be written \.

curl -XPUT '[http://localhost:9200/test/test/test](http://localhost:9200/test/test/test)' -d '  
{  
"rules": [  
{  
"users" : ["mile\kilo"]  
}  
]  
}'

--  
Magnus Bäck | Software Engineer, Development Tools  
[magnus.back@sonymobile.com](mailto:magnus.back@sonymobile.com) | Sony Mobile Communications

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/20140919064348.GE21271%40seldlx20533.corpusers.net](https://groups.google.com/d/msgid/elasticsearch/20140919064348.GE21271%40seldlx20533.corpusers.net).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:01am UTC](https://discuss.elastic.co/t/es-jsonparseexception/19853/5 "2017-07-06T01:01:06Z")

</div>


