0
votes

I'm building a logic app that pulls some JSON data from a REST API, parses it with the Parse JSON block, and pushes it to Azure Log Analytics. The main problem I'm hitting is an important JSON field can either be an object or null. Per this post I changed the relevant part of my JSON schema to something like this

"entity": {"type": ["object", "null"] }

While this works, I'm now no longer to access entity later in the logic app as dynamic content. I can access all other fields parsed by the Parse JSON block downstream in the logic (that don't have nullable field). If I remove the "null" option and just have the type set to object, I can access entity in dynamic content once again. Does anyone know why this might be happening and/or how to access the entity field downstream?

1

1 Answers

1
votes

Through the test, if we use "entity": {"type": ["object", "null"] }, we really cannot directly select entity in dynamic content.

But we can use the following expression to get the entity:

body('Parse_JSON')?['entity']

enter image description here

The test results seem to be no problem:

enter image description here

For a better understanding, let me cite a few more examples:

1. If your json is like this:

{
    "entity": {
        "testKey": "testValue"
    }
}

Your expression is like this:

body('Parse_JSON')?['entity'] 

2. If your json is like this:

{
    "test": {
        "entity": {
            "testKey": "testValue"
        }
    }
}

Your expression should like this:

body('Parse_JSON')?['test']?['entity']