# Inserting Quotes with mutate, gsub

**URL:** <https://discuss.elastic.co/t/inserting-quotes-with-mutate-gsub/41630>\
**Category:** Logstash\
**Created:** [February 12, 2016, 3:30pm UTC](https://discuss.elastic.co/t/inserting-quotes-with-mutate-gsub/41630 "2016-02-12T15:30:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxwell](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@maxwell](https://discuss.elastic.co/u/maxwell)\
**Post date:** [February 12, 2016, 3:30pm UTC](https://discuss.elastic.co/t/inserting-quotes-with-mutate-gsub/41630/1 "2016-02-12T15:30:04Z")

</div>

I have a json document which is failing json parse because some of the fields contain quotes, messing up the json. My solution is to remove all of the quotes, and then add them back in myself around relevant fields. However,

mutate =\> { gsub =\> ["", """, ""]  
gsub =\> ["", "my\_field", ""my\_field""]  
}

First removes all quotes, and then inserts literally " , i.e. the backslash used for escaping, AND the quote,

How can I insert a double-quote character without also inserting the slash?? (Ps. please don't tell me to add more backslashes, I've tried it lol)

---

<div class="post-metadata">

**Author:** ![maxwell](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@maxwell](https://discuss.elastic.co/u/maxwell)\
**Post date:** [February 12, 2016, 7:54pm UTC](https://discuss.elastic.co/t/inserting-quotes-with-mutate-gsub/41630/2 "2016-02-12T19:54:06Z")

</div>

I figured it out guys. If you use single quotes for gsub, you can put double quotes inside.

mutate =\> { gsub =\> ['', '"', ""]  
gsub =\> ['', 'my\_field', '"my\_field"']  
}

---

<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:11am UTC](https://discuss.elastic.co/t/inserting-quotes-with-mutate-gsub/41630/3 "2017-07-06T05:11:44Z")

</div>


