# Logstash convert number to string in array of objects

**URL:** <https://discuss.elastic.co/t/logstash-convert-number-to-string-in-array-of-objects/235741>\
**Category:** Logstash\
**Created:** [June 4, 2020, 11:15am UTC](https://discuss.elastic.co/t/logstash-convert-number-to-string-in-array-of-objects/235741 "2020-06-04T11:15:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mahebub\_Sayyed](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mahebub_sayyed/32/68237_2.png) [@Mahebub\_Sayyed](https://discuss.elastic.co/u/Mahebub_Sayyed)\
**Post date:** [June 4, 2020, 11:15am UTC](https://discuss.elastic.co/t/logstash-convert-number-to-string-in-array-of-objects/235741/1 "2020-06-04T11:15:56Z")

</div>

Hello,  
I have 2 logstash flows writing to the same index. For first flow value for "code" is number and for second flow its string. Please find the sample below

```auto
"Response": {
			"ResponsePayLoad": {
				"name": "OK",
				"statusDetails": [
					{
						"message": "OK",
						"code": 200
					}
				]
			}
}

```

```auto
"Response": {
			"ResponsePayLoad": {
				"name": "OK",
				"statusDetails": [
					{
						"message": "OK",
						"code": "422-01"
					}
				]
			}
}

```

I am getting parsingException for second flow while trying to convert to number.  
I want to convert code value in first flow from number to string in order to handle both flows.  
I tried below config, but its not working.

```auto
mutate {
        convert => {
          "message.Response.ResponsePayLoad.statusDetails.code" => "string"
        }

```

```auto
mutate {
        convert => {
          "message.Response.ResponsePayLoad.statusDetails[0].code" => "string"
        }
    }

```

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [June 4, 2020, 1:19pm UTC](https://discuss.elastic.co/t/logstash-convert-number-to-string-in-array-of-objects/235741/2 "2020-06-04T13:19:23Z")

</div>

> [@Mahebub\_Sayyed](#):
>
> `"message.Response.ResponsePayLoad.statusDetails[0].code" => "string"`

That should be

```
[Response][ResponsePayLoad][statusDetails][0][code]

```

---

<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 2, 2020, 1:19pm UTC](https://discuss.elastic.co/t/logstash-convert-number-to-string-in-array-of-objects/235741/3 "2020-07-02T13:19:31Z")

</div>

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