# Elasticsearch cannot parse the string value in json？

**URL:** <https://discuss.elastic.co/t/elasticsearch-cannot-parse-the-string-value-in-json/272793>\
**Category:** Elasticsearch\
**Created:** [May 12, 2021, 10:02am UTC](https://discuss.elastic.co/t/elasticsearch-cannot-parse-the-string-value-in-json/272793 "2021-05-12T10:02:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wajika](https://avatars.discourse-cdn.com/v4/letter/w/977dab/32.png) [@wajika](https://discuss.elastic.co/u/wajika)\
**Post date:** [May 12, 2021, 10:02am UTC](https://discuss.elastic.co/t/elasticsearch-cannot-parse-the-string-value-in-json/272793/1 "2021-05-12T10:02:32Z")

</div>

Failure when writing some json data to es with logstash.

> {"type"=\>"mapper\_parsing\_exception", "reason"=\>"object mapping for [Data.responsedto] tried to parse field [responsedto] as object, but found a concrete value"}

json data

```
{
	"SourceType": "ScmLog",
	"LogLevel": "info",
	"ApiName": "trade_push.php",
	"ApiUrl": "http://xxx.xx.cn/openapi2/trade_push.php",
	"Token": "",
	"Data": {
		"requestdto": [{
			"tid": "xxxxx-1",
			"trade_status": 30,
			"pay_status": 2,
			"delivery_term": 1,
			"trade_time": "2021-05-12T15:04:59",
			"pay_time": "2021-05-12T15:05:06",
			"fenxiao_type": null,
			"purchase_id": 0,
			"fenxiao_nick": null,
			"buyer_nick": "XXX",
			"buyer_email": null,
			"pay_id": "xxxxxx",
			"pay_account": null,
			"receiver_name": "xxx",
			"receiver_province": "xxxx",
			"receiver_city": "xxxx",
			"receiver_district": "xxx",
			"receiver_address": "xxxxx",
			"receiver_mobile": "xxxxxx",
			"receiver_telno": null,
			"receiver_zip": null,
			"logistics_type": null,
			"invoice_kind": null,
			"invoice_title": null,
			"invoice_content": null,
			"remark_flag": null,
			"buyer_message": "",
			"seller_memo": null,
			"seller_flag": null,
			"post_amount": null,
			"cod_amount": 0,
			"ext_cod_fee": 0,
			"other_amount": 0,
			"paid": 0.0,
			"id_card_type": null,
			"id_card": null,
			"is_auto_wms": null,
			"wms_type": null,
			"warehouse_no": null,
			"order_list": [{
				"oid": "xxxxxxxxxxx",
				"num": 0,
				"price": 0.0,
				"status": null,
				"refund_status": 2,
				"goods_id": "303",
				"spec_id": "303",
				"goods_no": null,
				"spec_no": "8010020014",
				"goods_name": "xxxx",
				"spec_name": "xxxxx",
				"adjust_amount": 0,
				"discount": null,
				"paid": 0.0,
				"share_discount": 0,
				"cid": 0,
				"remark": null
			}]
		}],
		"responsedto": "{\"code\":0,\"message\":\"\",\"error_count\":0,\"new_count\":0,\"chg_count\":1}"
	}
}

```

Is there any way to parse the string value in "responsedto"?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 12, 2021, 10:07am UTC](https://discuss.elastic.co/t/elasticsearch-cannot-parse-the-string-value-in-json/272793/2 "2021-05-12T10:07:32Z")

</div>

I'm moving your question to #elastic-stack:logstash as you will have probably to add some filters to extract the json from the string `Data.responsedto`.

The other solution, but it depends on what you are trying to do, is to change the mapping for elasticsearch and make `Data.responsedto` as a `text` field.  
Or just ignore completely its content but just store it in the source.

What are you trying to achieve here with that field?

---

<div class="post-metadata">

**Author:** ![wajika](https://avatars.discourse-cdn.com/v4/letter/w/977dab/32.png) [@wajika](https://discuss.elastic.co/u/wajika)\
**Post date:** [May 12, 2021, 10:42am UTC](https://discuss.elastic.co/t/elasticsearch-cannot-parse-the-string-value-in-json/272793/3 "2021-05-12T10:42:27Z")

</div>

> [@dadoonet](#):
>
> Data.responsedto

I only need "Data.responsedto" to be written into es.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 12, 2021, 1:06pm UTC](https://discuss.elastic.co/t/elasticsearch-cannot-parse-the-string-value-in-json/272793/4 "2021-05-12T13:06:40Z")

</div>

So change the mapping and set this field to `text`. And set `index` to `false` on this field as it won't make any sense IMO to index it.

Even better, set it to `"enabled": false`. See the example in [enabled | Elasticsearch Guide [7.12] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/enabled.html)

---

<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:** [June 9, 2021, 1:06pm UTC](https://discuss.elastic.co/t/elasticsearch-cannot-parse-the-string-value-in-json/272793/5 "2021-06-09T13:06:48Z")

</div>

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