# Parsing text and object

**URL:** <https://discuss.elastic.co/t/parsing-text-and-object/372219>\
**Category:** Logstash\
**Created:** [December 19, 2024, 10:35am UTC](https://discuss.elastic.co/t/parsing-text-and-object/372219 "2024-12-19T10:35:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vahagg1](https://avatars.discourse-cdn.com/v4/letter/v/7feea3/32.png) [@vahagg1](https://discuss.elastic.co/u/vahagg1)\
**Post date:** [December 19, 2024, 10:35am UTC](https://discuss.elastic.co/t/parsing-text-and-object/372219/1 "2024-12-19T10:35:14Z")

</div>

The problem which i face is like this:  
I have a single field like message which i want to parse it with json parser but sometimes the value which come to it is text and sometimes is json, I try to use regex like "^{._}[\s\S]_$" to check it is it json then rename or move it to other field name but the problem is sometimes it is not a valid json, is there any way to check what is the type like text or object and then start parsing?

---

<div class="post-metadata">

**Author:** ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)\
**Post date:** [December 19, 2024, 10:39am UTC](https://discuss.elastic.co/t/parsing-text-and-object/372219/2 "2024-12-19T10:39:54Z")

</div>

Most likely is possible with regex. Provide us with samples.

---

<div class="post-metadata">

**Author:** ![vahagg1](https://avatars.discourse-cdn.com/v4/letter/v/7feea3/32.png) [@vahagg1](https://discuss.elastic.co/u/vahagg1)\
**Post date:** [December 19, 2024, 10:45am UTC](https://discuss.elastic.co/t/parsing-text-and-object/372219/3 "2024-12-19T10:45:53Z")

</div>

It is a bit difficult to share the samples since there are in different kinds, As far as i check there is no option to handle this on elastic side without disabling mapping?

---

<div class="post-metadata">

**Author:** ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)\
**Post date:** [December 19, 2024, 11:11am UTC](https://discuss.elastic.co/t/parsing-text-and-object/372219/4 "2024-12-19T11:11:05Z")

</div>

Simplify, provide us with begging of lines, 1 or 2 samples. We don't need full message neither classified data such as an bank account number, IPs, etc...

You can use the ingest pipeline to process events. For mapping, it's not possible to changes field types without delete,create again.
