# Error parsing JSON doc

**URL:** <https://discuss.elastic.co/t/error-parsing-json-doc/29598>\
**Category:** Logstash\
**Created:** [September 18, 2015, 9:19pm UTC](https://discuss.elastic.co/t/error-parsing-json-doc/29598 "2015-09-18T21:19:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![FrankC](https://avatars.discourse-cdn.com/v4/letter/f/ed655f/32.png) [@FrankC](https://discuss.elastic.co/u/FrankC)\
**Post date:** [September 18, 2015, 9:19pm UTC](https://discuss.elastic.co/t/error-parsing-json-doc/29598/1 "2015-09-18T21:19:52Z")

</div>

Testing for the first time loading a json document with logstash. I am have logstash 1.5.1 and elastic 1.6.0. I get the error below. Any help is much appreciated.

Thanks in advance for taking a look.

json document:  
{  
"header":  
{  
"SenderID": "",  
"ReceiverID": "",  
"DocTypeID": "MasterBillOfLading",  
"DocCount": 1,  
"Date": {  
"type": "generation",  
"Text": "01/26/2015 15:28"  
}  
}  
}

config file:  
input {  
file  
{  
path =\> ["c:/test/mbol-header.json"]  
start\_position =\> "beginning"  
type =\> "extract"  
}  
}

filter  
{  
json{  
source =\> "message"  
}  
}

output  
{  
elasticsearch  
{  
host =\> "localhost"  
index =\> "dls"  
workers =\> 1  
document\_type =\> "mbol"  
}  
}

Error message (snippet):  
{:timestamp=\>"2015-09-18T15:51:13.505000-0500", :message=\>"Trouble parsing json", :source=\>"message", :raw=\>"{\r", :exception=\>#\<LogStash::Json::ParserError: Unexpected end-of-input: expected close marker for OBJECT (from [Source: [B@4250bacb; line: 1, column: 0])  
at [Source: [B@4250bacb; line: 2, column: 3]\>, :level=\>:warn}  
{:timestamp=\>"2015-09-18T15:51:13.511000-0500", :message=\>"Trouble parsing json", :source=\>"message", :raw=\>"\r", :exception=\>#\<LogStash::Json::ParserError: No content to map due to end-of-input  
at [Source: [B@312ae1ce; line: 1, column: 1]\>, :level=\>:warn}

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 19, 2015, 6:18am UTC](https://discuss.elastic.co/t/error-parsing-json-doc/29598/2 "2015-09-19T06:18:34Z")

</div>

Generally json is on a single like, if your message is like that then you'll probably need to use the multiline filter as well.

---

<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, 2015, 8:11am UTC](https://discuss.elastic.co/t/error-parsing-json-doc/29598/3 "2015-09-19T08:11:13Z")

</div>

Isn't the json codec supposed to support grabbing whole JSON documents from a stream? And json\_lines assumes one document per line?

But yes, with a json _filter_ you need to use a multiline filter or codec to join the lines of the document to a single message.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 19, 2015, 9:43am UTC](https://discuss.elastic.co/t/error-parsing-json-doc/29598/4 "2015-09-19T09:43:00Z")

</div>

Yep, good point.

---

<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, 5:28am UTC](https://discuss.elastic.co/t/error-parsing-json-doc/29598/5 "2017-07-06T05:28:39Z")

</div>


