title: JSON parse failure on valid JSON
body: <p>Here is my <code>logstash.conf</code> file:</p>
  
  <pre><code>input {
      http {
          host =&gt; "127.0.0.1"
          port =&gt; 31311 
          ssl =&gt; false
      }
  }
  
  filter {
      mutate {
          split =&gt; { "[headers][request_path]" =&gt; "/"}
          add_field =&gt; { "index_id" =&gt; "%{[headers][request_path][1]}" }
      }
  
      ruby { 
          code =&gt; "event.set('request_path_length', event.get('[headers][request_path]').length)" 
      }
  
      if [request_path_length] == 3 {
          mutate {
              add_field =&gt; { "document_id" =&gt; "%{[headers][request_path][2]}" }
          }
      }
  }
  
  output {
      stdout {
          codec =&gt; "json"
      }
  
      if [request_path_length] == 3 {
          elasticsearch {
              hosts =&gt; "http://localhost:9200"
              index =&gt; "%{index_id}"
              document_id =&gt; "%{document_id}"
          }
      }
      else {
          elasticsearch {
              hosts =&gt; "http://localhost:9200"
              index =&gt; "%{index_id}"
          }
      }
  }
  </code></pre>
  
  <p>Here is the command I ran in PowerShell:</p>
  
  <pre><code>PS C:\Users\Me\Downloads\curl-7.64.1-win64-mingw\bin&gt; .\curl.exe -H "content-type:application/json" -XPUT 'http://127.0.0.1:31311/bo
  ok/1' -d @"
  &gt;&gt; {"IndexId":"Book","DocumentId":"0","Title":"EKQXAQQSZAAUKVLKVHXAB","Edition":1,"Author":{"Name":"Mark Twain","Nationality":"France"},"Pu
  blisher":{"Name":"Harper Collins","HeadquartersAddress":{"Country":"Denmark","StreetName":"KRQAQIKTUTMTZ","PostalCode":"4539","State":"WOOS
  ESVGWIJDZSZ"}}}
  &gt;&gt; "@
  </code></pre>
  
  <p>Here is what I see in my LogStash terminal:</p>
  
  <pre><code>[2019-04-10T12:36:00,232][ERROR][logstash.codecs.json     ] JSON parse error, original data now in message field {:error=&gt;#&lt;LogStash::Json::ParserError: Unexpected character ('I' (code 73)): was expecting double-quote to start field name
   at [Source: (String)"{IndexId:Book,DocumentId:0,Title:EKQXAQQSZAAUKVLKVHXAB,Edition:1,Author:{Name:Mark Twain,Nationality:France},Publisher:{Name:Harper Collins,HeadquartersAddress:{Country:Denmark,StreetName:KRQAQIKTUTMTZ,PostalCode:4539,State:WOOSESVGWIJDZSZ}}}"; line: 1, column: 3]&gt;, :data=&gt;"{IndexId:Book,DocumentId:0,Title:EKQXAQQSZAAUKVLKVHXAB,Edition:1,Author:{Name:Mark Twain,Nationality:France},Publisher:{Name:Harper Collins,HeadquartersAddress:{Country:Denmark,StreetName:KRQAQIKTUTMTZ,PostalCode:4539,State:WOOSESVGWIJDZSZ}}}"}
  {"message":"{IndexId:Book,DocumentId:0,Title:EKQXAQQSZAAUKVLKVHXAB,Edition:1,Author:{Name:Mark Twain,Nationality:France},Publisher:{Name:Harper Collins,HeadquartersAddress:{Country:Denmark,StreetName:KRQAQIKTUTMTZ,PostalCode:4539,State:WOOSESVGWIJDZSZ}}}","document_id":"1","@version":"1","@timestamp":"2019-04-10T12:36:00.233Z","index_id":"book","request_path_length":3,"tags":["_jsonparsefailure"],"headers":{"content_type":"application/json","request_path":["","book","1"],"http_accept":"*/*","http_version":"HTTP/1.1","content_length":"242","request_method":"PUT","http_user_agent":"curl/7.64.1","http_host":"127.0.0.1:31311"},"host":"127.0.0.1"}
  </code></pre>
  
  <p>I am not sure why there was a JSON parse failure -- my JSON sample passes the validation test <a href="https://codebeautify.org/jsonvalidator" rel="nofollow noreferrer">here</a>.</p>
  
  <p>How can I fix this issue?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I ran a slightly different command:</p>
  
  <blockquote>
    <p>PS C:\Users\Me\Downloads\curl-7.64.1-win64-mingw\bin> .\curl.exe -H
    "content-type:application/json" -XPUT '<a href="http://127.0.0.1:31311/bo" rel="nofollow noreferrer">http://127.0.0.1:31311/bo</a> ok/1'
    -d '{\"IndexId\":\"Book\",\"DocumentId\":\"0\",\"Title\":\"EKQXAQQSZAAUKVLKVHXAB\",\"Edition\":\"1\",\"Author\":{\"Name\":\"Mark
    Twai n\",\"Nationality\":"France\"},\"Publisher\":{\"Name\":\"Harper
    Collins\",\"HeadquartersAddress\":{\"Country\":\"Denmark\",\"StreetName\":\
    "KRQAQIKTUTMTZ\",\"PostalCode\":\"4539\",\"State\":\"WOOSESVGWIJDZSZ\"}}}'</p>
  </blockquote>
  
  <p>This time, I saw this error message in my LogStash terminal:</p>
  
  <pre><code>[2019-04-10T12:53:03,799][ERROR][logstash.codecs.json     ] JSON parse error, original data now in message field {:error=&gt;#&lt;LogStash::Json::ParserError: Unexpected end-of-input: was expecting closing quote for a string value
   at [Source: (String)"{"IndexId":"Book","DocumentId":"0","Title":"EKQXAQQSZAAUKVLKVHXAB","Edition":"1","Author":{"Name":"Mark"; line: 1, column: 207]&gt;, :data=&gt;"{\"IndexId\":\"Book\",\"DocumentId\":\"0\",\"Title\":\"EKQXAQQSZAAUKVLKVHXAB\",\"Edition\":\"1\",\"Author\":{\"Name\":\"Mark"}
  {"message":"{\"IndexId\":\"Book\",\"DocumentId\":\"0\",\"Title\":\"EKQXAQQSZAAUKVLKVHXAB\",\"Edition\":\"1\",\"Author\":{\"Name\":\"Mark","tags":["_jsonparsefailure"],"@version":"1","@timestamp":"2019-04-10T12:53:03.813Z","headers":{"http_version":"HTTP/1.1","http_user_agent":"curl/7.64.1","content_length":"103","request_method":"PUT","http_accept":"*/*","request_path":["","book","1"],"content_type":"application/json","http_host":"127.0.0.1:31311"},"host":"127.0.0.1","index_id":"book","document_id":"1","request_path_length":3}
  </code></pre>