JSON Microgateway 4.1

Hi there! :wave:

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

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:

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

But it didn’t…

Thanks,
Markus

This is a viable workaround for me:

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

Still interested what can be done with “key” :wink:

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:

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

Or like you configured it.

Key can be used in JSON objects like this:

{
   "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

Hi Stefan

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

{"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 :wink:

Thanks,
Markus

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