# JSON Microgateway 4.1

**URL:** <https://forum.airlock.com/t/json-microgateway-4-1/166>\
**Category:** Ask the community\
**Created:** [October 20, 2023, 2:09pm UTC](https://forum.airlock.com/t/json-microgateway-4-1/166 "2023-10-20T14:09:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhe](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@mhe](https://forum.airlock.com/u/mhe)\
**Post date:** [October 20, 2023, 2:09pm UTC](https://forum.airlock.com/t/json-microgateway-4-1/166/1 "2023-10-20T14:09:38Z")

</div>

Hi there! 👋

Can anyone provide an example of a deny rule exception for JSON “key” with MGW4.1?

> **[DenyRules :: Airlock Microgateway API](https://docs.airlock.com/microgateway/4.1/api/crds/deny-rules/v1alpha1/index.html#denyrulesspecrequestbuiltinexceptionsblockeddatajsonkey)**
>
> API version v1alpha1

I wrote some exceptions with jsonpath, but didn’t get it to work with “key”.

Here an extract from the logs:  
“json\_path”: “$[‘translations’][0][‘text2’]”

problem: It can also be “text1” “text0” or any other number for text. I hoped a rule like this might work:

```auto
        - blockedData:
            json:
              key:
                matcher:
                  contains: text

```

But it didn’t…

Thanks,  
Markus

---

<div class="post-metadata">

**Author:** ![mhe](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@mhe](https://forum.airlock.com/u/mhe)\
**Post date:** [October 20, 2023, 3:45pm UTC](https://forum.airlock.com/t/json-microgateway-4-1/166/2 "2023-10-20T15:45:58Z")

</div>

This is a viable workaround for me:

```auto
jsonPath: $['translations'][*]['text1','text2','textn']

```

Still interested what can be done with “key” 😉

---

<div class="post-metadata">

**Author:** ![dieti](https://avatars.discourse-cdn.com/v4/letter/d/41988e/32.png) [@dieti](https://forum.airlock.com/u/dieti)\
**Post date:** [October 24, 2023, 12:42pm UTC](https://forum.airlock.com/t/json-microgateway-4-1/166/3 "2023-10-24T12:42:02Z")

</div>

Hi Markus

I am quite certain that in your example “text0”, “text1”, … is not a key, but a value.  
Therefore, you should change the configuration to:

```auto
- blockedData:
            json:
              value:
                matcher:
                  prefix: text

```

Or like you configured it.

Key can be used in JSON objects like this:

```auto
{
   "firstName": "John",    
   "lastName": "Doe",    
   "phoneNumbers": [        
      {            
         "type": "home",            
         "number": "0235066090"       
      },        
      {            
         "type": "mobile",            
         "number": "0648417050"
      }    
   ]
}

```

In the above example, firstName and lastName are keys which contains only one value.  
phoneNumbers is a key, which contains a list. The list itself also has key/values.

I hope this makes it more clear.

Cheers  
Stefan

---

<div class="post-metadata">

**Author:** ![mhe](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@mhe](https://forum.airlock.com/u/mhe)\
**Post date:** [October 25, 2023, 12:17pm UTC](https://forum.airlock.com/t/json-microgateway-4-1/166/4 "2023-10-25T12:17:39Z")

</div>

Hi Stefan

Thanks for your reply. Se the below, real example:

```auto
{"id":10001,"translations":[{"id":10010,"created_date":"2021-10-20T14:00:00+02:00","modified_date":"2021-10-20T14:00:00+02:00","language_code":"de","url":"","subject":"SOC Meldung / [[[verdict]]] / Link geklickt/ #[[soc_id]]","text1":"<p>Liebes SOC Team</p>\n\n<p>Gem&auml;ss Meldung hat die Empf&auml;ngerin oder der Empf&auml;nger auf den Link geklickt.</p>\n\n<p>&nbsp;</p>\n\n<p>test1</p>\n","text2":"<p>Freundliche Grüsse<br>das team</p>","template":10001}],"template_type":"soc_email_clicked","can_delete":null,"created_date":"2021-10-20T14:00:00+02:00","modified_date":"2021-10-20T14:00:00+02:00","account":null}

```

To my understanding text1 and text2 are keys and not values, correct?

You can also guess from the example why we need deny rule exceptions here 😉

Thanks,  
Markus

---

<div class="post-metadata">

**Author:** ![dieti](https://avatars.discourse-cdn.com/v4/letter/d/41988e/32.png) [@dieti](https://forum.airlock.com/u/dieti)\
**Post date:** [October 27, 2023, 5:44am UTC](https://forum.airlock.com/t/json-microgateway-4-1/166/5 "2023-10-27T05:44:45Z")

</div>

Hi Markus

Yes, I would also assume that text1 and text2 are threated as key.  
By only creating a deny rule exception based on the key name, this key could be anywhere in the JSON object. If you combine it with a JsonPath or only define it with JsonPath, the key must be at the specified place.

Cheers  
Stefan
