Accessing entities with @ in name for JSON - JSON mapping

119 views Asked by At

I have got my Liquid map working for all other entities but if I try to rename for e.g. @odata.etag object to odata.etag the map's output is an empty string so I guess it cannot access the entity with "@" in it. Another example of this is on OData API which has a "friendly name" e.g. [email protected]. I can access and remap code but if I try to remap the friendly name it outputs an empty string.

I tried to use the following Liquid template:

[
        {%- for i in body.value -%}
        {
        "etag": "{{[email protected]}}", //This does not work
        "type": "{{i.type}}", // This works
        "typename": "{{[email protected]}}" //This does not work
        }
        {%- if forloop.last == false -%}
        ,
        {%- endif -%}
        {%- endfor -%}
]

Example payload:

{
    "@odata.context": "",
    "value": [
        {
            "@odata.etag": "1",
            "type": "0001",
            "[email protected]": "Normal",
        }
    ]
}
1

There are 1 answers

0
Fritz von Rock On

I hit a similar situation working with OData formatted values using liquid in an Azure logic app. Hopefully my workaround works for you too in your environment.

Workaround: The workaround I found was to change the x.y@z reference into a x['y@z'] reference, using square brackets and single quotes rather than the dot to specify the field with the '@' in its name.

e.g. for your case:

"{{[email protected]}}"

becomes

"{{i['[email protected]']}}"