# XContentBuilder.copyCurrentStructure() fails with .JsonParseException: Unexpected end-of-input expected close marker for OBJECT

**URL:** <https://discuss.elastic.co/t/xcontentbuilder-copycurrentstructure-fails-with-jsonparseexception-unexpected-end-of-input-expected-close-marker-for-object/14025>\
**Category:** Elasticsearch\
**Created:** [October 19, 2013, 8:39am UTC](https://discuss.elastic.co/t/xcontentbuilder-copycurrentstructure-fails-with-jsonparseexception-unexpected-end-of-input-expected-close-marker-for-object/14025 "2013-10-19T08:39:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hendrik](https://avatars.discourse-cdn.com/v4/letter/h/839c29/32.png) [@Hendrik](https://discuss.elastic.co/u/Hendrik)\
**Post date:** [October 19, 2013, 8:39am UTC](https://discuss.elastic.co/t/xcontentbuilder-copycurrentstructure-fails-with-jsonparseexception-unexpected-end-of-input-expected-close-marker-for-object/14025/1 "2013-10-19T08:39:30Z")

</div>

$ curl -XGET '[http://localhost:9200/\_search](http://localhost:9200/_search)' -d '{  
"query" : {  
"term" : { "user" : "kimchy" }  
}  
'

public class MyRestFilterDoingSpecialThings extends RestFilter {  
...  
Override  
public void process(RestRequest request, RestChannel channel,  
RestFilterChain filterChain) { ...

XContentType xContentType =  
XContentFactory.xContentType(request.content()); //json  
XContentParser parser =  
XContentFactory.xContent(xContentType).createParser(request.content());  
XContentParser.Token t = parser.nextToken();  
//t is START\_OBJECT  
XContentBuilder builder =  
XContentFactory.contentBuilder( xContentType).copyCurrentStructure(parser);  
\<-- fails with

org.elasticsearch.common.jackson.core.JsonParseException: Unexpected  
end-of-input: expected close marker for OBJECT (from [Source: [B@29569b73; line: 1, column: 0])  
at [Source: [B@29569b73; line: 5, column: 64]  
at  
org.elasticsearch.common.jackson.core.JsonParser.\_constructError(JsonParser.java:1369)  
at  
org.elasticsearch.common.jackson.core.base.ParserMinimalBase.\_reportError(ParserMinimalBase.java:532)  
at  
org.elasticsearch.common.jackson.core.base.ParserMinimalBase.\_reportInvalidEOF(ParserMinimalBase.java:465)  
at  
org.elasticsearch.common.jackson.core.base.ParserBase.\_handleEOF(ParserBase.java:491)  
at  
org.elasticsearch.common.jackson.core.json.UTF8StreamJsonParser.\_skipWSOrEnd(UTF8StreamJsonParser.java:2513)  
at  
org.elasticsearch.common.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:617)  
at  
org.elasticsearch.common.jackson.core.base.GeneratorBase.copyCurrentStructure(GeneratorBase.java:401)  
at  
org.elasticsearch.common.xcontent.json.JsonXContentGenerator.copyCurrentStructure(JsonXContentGenerator.java:310)  
at  
org.elasticsearch.common.xcontent.XContentBuilder.copyCurrentStructure(XContentBuilder.java:1035)

What did i wrong?  
Thanks  
Hendrik

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![johtani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johtani/32/44956_2.png) [@johtani](https://discuss.elastic.co/u/johtani)\
**Post date:** [October 20, 2013, 4:07pm UTC](https://discuss.elastic.co/t/xcontentbuilder-copycurrentstructure-fails-with-jsonparseexception-unexpected-end-of-input-expected-close-marker-for-object/14025/2 "2013-10-20T16:07:23Z")

</div>

Hi Hendrik,

Your query lack last close brace.  
Maybe this error say "incorrect JSON object ".

2013/10/19 Hendrik [h.j.saly@googlemail.com](mailto:h.j.saly@googlemail.com)

> $ curl -XGET '[http://localhost:9200/\_search](http://localhost:9200/_search)' -d '{  
> "query" : {  
> "term" : { "user" : "kimchy" }  
> }  
> '
> 
> public class MyRestFilterDoingSpecialThings extends RestFilter {  
> ...  
> Override  
> public void process(RestRequest request, RestChannel channel,  
> RestFilterChain filterChain) { ...
> 
> XContentType xContentType =  
> XContentFactory.xContentType(request.content()); //json  
> XContentParser parser =  
> XContentFactory.xContent(xContentType).createParser(request.content());  
> XContentParser.Token t = parser.nextToken();  
> //t is START\_OBJECT  
> XContentBuilder builder =  
> XContentFactory.contentBuilder( xContentType).copyCurrentStructure(parser);  
> \<-- fails with
> 
> org.elasticsearch.common.jackson.core.JsonParseException: Unexpected  
> end-of-input: expected close marker for OBJECT (from [Source: [B@29569b73;  
> line: 1, column: 0])  
> at [Source: [B@29569b73; line: 5, column: 64]  
> at  
> org.elasticsearch.common.jackson.core.JsonParser.\_constructError(JsonParser.java:1369)  
> at  
> org.elasticsearch.common.jackson.core.base.ParserMinimalBase.\_reportError(ParserMinimalBase.java:532)  
> at  
> org.elasticsearch.common.jackson.core.base.ParserMinimalBase.\_reportInvalidEOF(ParserMinimalBase.java:465)  
> at  
> org.elasticsearch.common.jackson.core.base.ParserBase.\_handleEOF(ParserBase.java:491)  
> at  
> org.elasticsearch.common.jackson.core.json.UTF8StreamJsonParser.\_skipWSOrEnd(UTF8StreamJsonParser.java:2513)  
> at  
> org.elasticsearch.common.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:617)  
> at  
> org.elasticsearch.common.jackson.core.base.GeneratorBase.copyCurrentStructure(GeneratorBase.java:401)  
> at  
> org.elasticsearch.common.xcontent.json.JsonXContentGenerator.copyCurrentStructure(JsonXContentGenerator.java:310)  
> at  
> org.elasticsearch.common.xcontent.XContentBuilder.copyCurrentStructure(XContentBuilder.java:1035)
> 
> What did i wrong?  
> Thanks  
> Hendrik
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

## --

Jun Ohtani  
blog : [http://blog.johtani.info](http://blog.johtani.info)

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Hendrik](https://avatars.discourse-cdn.com/v4/letter/h/839c29/32.png) [@Hendrik](https://discuss.elastic.co/u/Hendrik)\
**Post date:** [October 22, 2013, 4:00pm UTC](https://discuss.elastic.co/t/xcontentbuilder-copycurrentstructure-fails-with-jsonparseexception-unexpected-end-of-input-expected-close-marker-for-object/14025/3 "2013-10-22T16:00:49Z")

</div>

Awkward[http://dict.leo.org/#/search=awkward&searchLoc=0&resultOrder=basic&multiwordShowSingle=on](http://dict.leo.org/#/search=awkward&searchLoc=0&resultOrder=basic&multiwordShowSingle=on),  
thanks.  
Typical example for not[http://dict.leo.org/#/search=not&searchLoc=0&resultOrder=basic&multiwordShowSingle=on](http://dict.leo.org/#/search=not&searchLoc=0&resultOrder=basic&multiwordShowSingle=on)  
to[http://dict.leo.org/#/search=to&searchLoc=0&resultOrder=basic&multiwordShowSingle=on](http://dict.leo.org/#/search=to&searchLoc=0&resultOrder=basic&multiwordShowSingle=on)  
see[http://dict.leo.org/#/search=see&searchLoc=0&resultOrder=basic&multiwordShowSingle=on](http://dict.leo.org/#/search=see&searchLoc=0&resultOrder=basic&multiwordShowSingle=on)  
the[http://dict.leo.org/#/search=the&searchLoc=0&resultOrder=basic&multiwordShowSingle=on](http://dict.leo.org/#/search=the&searchLoc=0&resultOrder=basic&multiwordShowSingle=on)  
wood[http://dict.leo.org/#/search=wood&searchLoc=0&resultOrder=basic&multiwordShowSingle=on](http://dict.leo.org/#/search=wood&searchLoc=0&resultOrder=basic&multiwordShowSingle=on)  
for[http://dict.leo.org/#/search=for&searchLoc=0&resultOrder=basic&multiwordShowSingle=on](http://dict.leo.org/#/search=for&searchLoc=0&resultOrder=basic&multiwordShowSingle=on)  
the[http://dict.leo.org/#/search=the&searchLoc=0&resultOrder=basic&multiwordShowSingle=on](http://dict.leo.org/#/search=the&searchLoc=0&resultOrder=basic&multiwordShowSingle=on)  
trees[http://dict.leo.org/#/search=trees&searchLoc=0&resultOrder=basic&multiwordShowSingle=on](http://dict.leo.org/#/search=trees&searchLoc=0&resultOrder=basic&multiwordShowSingle=on)  
🙂

Am Sonntag, 20. Oktober 2013 18:07:23 UTC+2 schrieb Jun Ohtani:

> Hi Hendrik,
> 
> Your query lack last close brace.  
> Maybe this error say "incorrect JSON object ".
> 
> 2013/10/19 Hendrik \<[h.j....@googlemail.com](mailto:h.j....@googlemail.com) \<javascript:\>\>
> 
> > $ curl -XGET '[http://localhost:9200/\_search](http://localhost:9200/_search)' -d '{  
> > "query" : {  
> > "term" : { "user" : "kimchy" }  
> > }  
> > '
> > 
> > public class MyRestFilterDoingSpecialThings extends RestFilter {  
> > ...  
> > Override  
> > public void process(RestRequest request, RestChannel channel,  
> > RestFilterChain filterChain) { ...
> > 
> > XContentType xContentType =  
> > XContentFactory.xContentType(request.content()); //json  
> > XContentParser parser =  
> > XContentFactory.xContent(xContentType).createParser(request.content());  
> > XContentParser.Token t = parser.nextToken();  
> > //t is START\_OBJECT  
> > XContentBuilder builder =  
> > XContentFactory.contentBuilder( xContentType).copyCurrentStructure(parser);  
> > \<-- fails with
> > 
> > org.elasticsearch.common.jackson.core.JsonParseException: Unexpected  
> > end-of-input: expected close marker for OBJECT (from [Source: [B@29569b73; line: 1, column: 0])  
> > at [Source: [B@29569b73; line: 5, column: 64]  
> > at  
> > org.elasticsearch.common.jackson.core.JsonParser.\_constructError(JsonParser.java:1369)  
> > at  
> > org.elasticsearch.common.jackson.core.base.ParserMinimalBase.\_reportError(ParserMinimalBase.java:532)  
> > at  
> > org.elasticsearch.common.jackson.core.base.ParserMinimalBase.\_reportInvalidEOF(ParserMinimalBase.java:465)  
> > at  
> > org.elasticsearch.common.jackson.core.base.ParserBase.\_handleEOF(ParserBase.java:491)  
> > at  
> > org.elasticsearch.common.jackson.core.json.UTF8StreamJsonParser.\_skipWSOrEnd(UTF8StreamJsonParser.java:2513)  
> > at  
> > org.elasticsearch.common.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:617)  
> > at  
> > org.elasticsearch.common.jackson.core.base.GeneratorBase.copyCurrentStructure(GeneratorBase.java:401)  
> > at  
> > org.elasticsearch.common.xcontent.json.JsonXContentGenerator.copyCurrentStructure(JsonXContentGenerator.java:310)  
> > at  
> > org.elasticsearch.common.xcontent.XContentBuilder.copyCurrentStructure(XContentBuilder.java:1035)
> > 
> > What did i wrong?  
> > Thanks  
> > Hendrik
> > 
> > --  
> > 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:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> ## --
> 
> Jun Ohtani  
> blog : [http://blog.johtani.info](http://blog.johtani.info)

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Bharathi\_Raja](https://avatars.discourse-cdn.com/v4/letter/b/3d9bf3/32.png) [@Bharathi\_Raja](https://discuss.elastic.co/u/Bharathi_Raja)\
**Post date:** [December 20, 2014, 2:21am UTC](https://discuss.elastic.co/t/xcontentbuilder-copycurrentstructure-fails-with-jsonparseexception-unexpected-end-of-input-expected-close-marker-for-object/14025/4 "2014-12-20T02:21:45Z")

</div>

Hi,  
CREATE EXTERNAL TABLE message (  
messageId string,  
messageSize int,  
sender string,  
recipients array,  
messageParts array\<struct\<  
extension: string,  
size: int\>\>,  
headers map\<string,string\>  
)ROW FORMAT SERDE 'com.cloudera.hive.serde.JSONSerDe'  
LOCATION '/Loca1';

JSON:  
{  
"messageId": "34dd0d3c-f53b-11e0-ac12-d3e782dff199",  
"messageSize": 12345,  
"sender": "[alice@example.com](mailto:alice@example.com)",  
"recipients": [  
"[joe@example.com](mailto:joe@example.com)",  
"[bob@example.com](mailto:bob@example.com)"  
],  
"messageParts": [  
{  
"extension": "pdf",  
"size": 4567  
},  
{  
"extension": "jpg",  
"size": 9451  
}  
],  
"headers": {  
"Received-SPF": "pass",  
"X-Broadcast-Id": "9876"  
}  
}

I get JSONParseException with unexpected end-of-input. Could you please  
correct?

On Saturday, October 19, 2013 2:09:30 PM UTC+5:30, Hendrik wrote:

> $ curl -XGET '[http://localhost:9200/\_search](http://localhost:9200/_search)' -d '{  
> "query" : {  
> "term" : { "user" : "kimchy" }  
> }  
> '
> 
> public class MyRestFilterDoingSpecialThings extends RestFilter {  
> ...  
> Override  
> public void process(RestRequest request, RestChannel channel,  
> RestFilterChain filterChain) { ...
> 
> XContentType xContentType =  
> XContentFactory.xContentType(request.content()); //json  
> XContentParser parser =  
> XContentFactory.xContent(xContentType).createParser(request.content());  
> XContentParser.Token t = parser.nextToken();  
> //t is START\_OBJECT  
> XContentBuilder builder =  
> XContentFactory.contentBuilder( xContentType).copyCurrentStructure(parser);  
> \<-- fails with
> 
> org.elasticsearch.common.jackson.core.JsonParseException: Unexpected  
> end-of-input: expected close marker for OBJECT (from [Source: [B@29569b73; line: 1, column: 0])  
> at [Source: [B@29569b73; line: 5, column: 64]  
> at  
> org.elasticsearch.common.jackson.core.JsonParser.\_constructError(JsonParser.java:1369)  
> at  
> org.elasticsearch.common.jackson.core.base.ParserMinimalBase.\_reportError(ParserMinimalBase.java:532)  
> at  
> org.elasticsearch.common.jackson.core.base.ParserMinimalBase.\_reportInvalidEOF(ParserMinimalBase.java:465)  
> at  
> org.elasticsearch.common.jackson.core.base.ParserBase.\_handleEOF(ParserBase.java:491)  
> at  
> org.elasticsearch.common.jackson.core.json.UTF8StreamJsonParser.\_skipWSOrEnd(UTF8StreamJsonParser.java:2513)  
> at  
> org.elasticsearch.common.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:617)  
> at  
> org.elasticsearch.common.jackson.core.base.GeneratorBase.copyCurrentStructure(GeneratorBase.java:401)  
> at  
> org.elasticsearch.common.xcontent.json.JsonXContentGenerator.copyCurrentStructure(JsonXContentGenerator.java:310)  
> at  
> org.elasticsearch.common.xcontent.XContentBuilder.copyCurrentStructure(XContentBuilder.java:1035)
> 
> What did i wrong?  
> Thanks  
> Hendrik

--  
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/162685e1-d872-474c-a30f-a651bf7ceb5d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/162685e1-d872-474c-a30f-a651bf7ceb5d%40googlegroups.com).  
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, 12:42am UTC](https://discuss.elastic.co/t/xcontentbuilder-copycurrentstructure-fails-with-jsonparseexception-unexpected-end-of-input-expected-close-marker-for-object/14025/5 "2017-07-06T00:42:36Z")

</div>


