# DQL Processing Rule with Brackets in JSON

**URL:** <https://community.dynatrace.com/t/dql-processing-rule-with-brackets-in-json/46054>\
**Category:** DQL\
**Tags:** dql, logs\
**Created:** [June 11, 2024, 4:24pm UTC](https://community.dynatrace.com/t/dql-processing-rule-with-brackets-in-json/46054 "2024-06-11T16:24:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanielS](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@DanielS](https://community.dynatrace.com/u/DanielS)\
**Post date:** [June 11, 2024, 4:24pm UTC](https://community.dynatrace.com/t/dql-processing-rule-with-brackets-in-json/46054/1 "2024-06-11T16:24:36Z")

</div>

Hello Community,

I have this DQL Processing issue:

For this log

```markup
{
"event.type": "LOG",
"content": "{\"clientId\":\"35edd03e-84cd-4c7b-831d-e8318fbcfc06\",\"context\":\"ValidationService\",\"extras\":{\"errorCode\":\"PART_OF_DOCUMENT_MISSING\",\"retrievalData\":{\"capability\":\"usability\",\"data\":{},\"reason\":\"PART_OF_DOCUMENT_MISSING\",\"status\":\"REJECTED\"}},\"level\":\"info\",\"message\":\"Validation failed\",\"timestamp\":\"2024-06-11T14:00:05.649Z\",\"traceId\":\"97f9b7bd-a9ff-4c3d-8494-f28171e74bff\"}",
"status": "NONE",
"timestamp": "1718114405649"
}

```

I have this processing rule:

```markup
PARSE(content, "
JSON{
  STRING:clientId,
  JSON {STRING:errorCode}:extras
}:parsedJson")
| FIELDS_ADD(top_level.attribute1: parsedJson["clientId"], top_level.attribute2: parsedJson["extras"]["errorCode"])
| FIELDS_REMOVE(parsedJson)

```

and my output is :

```markup
"top_level.attribute1": "35edd03e-84cd-4c7b-831d-e8318fbcfc06",
  "top_level.attribute2": "PART_OF_DOCUMENT_MISSING",

```

Great, but this is only to probe that the rule is working, the original log has brackets in the nested extras:

```markup
{
"event.type": "LOG",
"content": "{\"clientId\":\"35edd03e-84cd-4c7b-831d-e8318fbcfc06\",\"context\":\"ValidationService\",\"extras\":[{\"errorCode\":\"PART_OF_DOCUMENT_MISSING\",\"retrievalData\":{\"capability\":\"usability\",\"data\":{},\"reason\":\"PART_OF_DOCUMENT_MISSING\",\"status\":\"REJECTED\"}}],\"level\":\"info\",\"message\":\"Validation failed\",\"timestamp\":\"2024-06-11T14:00:05.649Z\",\"traceId\":\"97f9b7bd-a9ff-4c3d-8494-f28171e74bff\"}",
"status": "NONE",
"timestamp": "1718114405649"
}

```

and with this brackets the parse won’t work, how can I&nbsp; modify the processing rule to retrieve the nested errorCode field?

Thanks

---

<div class="post-metadata">

**Author:** ![mark\_bley](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mark_bley/32/20954_2.png) [@mark\_bley](https://community.dynatrace.com/u/mark_bley)\
**Post date:** [June 11, 2024, 7:12pm UTC](https://community.dynatrace.com/t/dql-processing-rule-with-brackets-in-json/46054/2 "2024-06-11T19:12:55Z")

</div>

That is a json array try this:

```markup
PARSE(content, "
JSON{
  STRING:clientId,
  JSON_ARRAY { JSON }:extras
}:parsedJson")
| FIELDS_ADD(top_level.attribute1: parsedJson["clientId"], top_level.attribute2: parsedJson["extras"][0]["errorCode"])
| FIELDS_REMOVE(parsedJson)

```

---

<div class="post-metadata">

**Author:** ![DanielS](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@DanielS](https://community.dynatrace.com/u/DanielS)\
**Post date:** [June 11, 2024, 7:54pm UTC](https://community.dynatrace.com/t/dql-processing-rule-with-brackets-in-json/46054/3 "2024-06-11T19:54:58Z")

</div>

Thanks [@mark\_bley](https://community.dynatrace.com/user/13072) !!! Just to understand that [0] is the index of the attribute inside the array? if I need to recover something inside second level of nested retrievalData? I cannot found those examples in the [doc](https://docs.dynatrace.com/docs/shortlink/lma-log-processing-examples).

---

<div class="post-metadata">

**Author:** ![mark\_bley](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mark_bley/32/20954_2.png) [@mark\_bley](https://community.dynatrace.com/u/mark_bley)\
**Post date:** [June 12, 2024, 7:11am UTC](https://community.dynatrace.com/t/dql-processing-rule-with-brackets-in-json/46054/4 "2024-06-12T07:11:45Z")

</div>

1. Correct
2. Use either an index or key, depending on the type of object you access

You can find more detailed info regarding DPL here&nbsp;[DPL JSON Data — Dynatrace Docs](https://docs.dynatrace.com/docs/shortlink/dpl-json-arrays)
