# Parsing JSON along with double Quotes

**URL:** <https://discuss.elastic.co/t/parsing-json-along-with-double-quotes/105645>\
**Category:** Logstash\
**Created:** [October 28, 2017, 7:24pm UTC](https://discuss.elastic.co/t/parsing-json-along-with-double-quotes/105645 "2017-10-28T19:24:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ranjith](https://avatars.discourse-cdn.com/v4/letter/r/8797f3/32.png) [@ranjith](https://discuss.elastic.co/u/ranjith)\
**Post date:** [October 28, 2017, 7:24pm UTC](https://discuss.elastic.co/t/parsing-json-along-with-double-quotes/105645/1 "2017-10-28T19:24:07Z")

</div>

Hi all,

I am trying to parse the following json which contains spec field.

> {"multiplier":1,"name":"bullet","spec":"Deluxe Sink, two compartment, 87"W x 30"D x 41"H, 16/300 stainless steel, 24" x 24" x 11-1/2" deep compartments, 36" with stainless steel adjustable feet, NSF"}

To get the output as in csv with every field enclosed by double quotes.  
For eg: "1","bullet","Deluxe Sink,.......................,NSF"

To get enclosed with double quotes , i am adding a Quotes field in filter and concatenating it with the file input plugin

> filter  
> { mutate {add\_field =\> {"Quotes" =\> ' " '} }  
> }

> output {file {  
> path =\> ["E:\work\logstash\logstash-5.5.0\input\FOB.csv"]  
> codec =\> line { format =\> "%{Quotes}%{multiplier}%{Quotes},%{Quotes}%{name}%{Quotes},%{Quotes}%{spec}%{Quotes}"}  
> }  
> }

But the comma inside the spec field is being separated to other fields

Please guide me , Thanks in Advance

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [October 29, 2017, 8:37pm UTC](https://discuss.elastic.co/t/parsing-json-along-with-double-quotes/105645/2 "2017-10-29T20:37:59Z")

</div>

The JSON string you provided is not valid JSON. To make this valid JSON you need to escape the quotes within the spec field:

```
{
	"multiplier": 1,
	"name": "bullet",
	"spec": "Deluxe Sink, two compartment, 87\"W x 30\"D x 41\"H, 16/300 stainless steel, 24\" x 24\" x 11-1/2\" deep compartments, 36\" with stainless steel adjustable feet, NSF"
}

```

Easiest way to sort this might be to change the source to emit valid JSON so that you can use the json filter.

---

<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:** [November 26, 2017, 8:38pm UTC](https://discuss.elastic.co/t/parsing-json-along-with-double-quotes/105645/3 "2017-11-26T20:38:13Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
