Search code examples
jsonazureazure-data-factoryexpressionbuilder

Azure Data Factory Expression Builder: Error Structuring JSON with Nested Arrays and Objects


I've been working on this for a couple of days now and am reaching out for assistance. I was unable to structure the format properly and need help.

I've been trying to create a JSON structure in Azure Data Factory (ADF) using the Expression Builder, but I'm encountering an error. Here's the JSON structure I want to achieve:

{
  "entity_id": "value1",
  "link_id": "value2",
  "url": "value3",
  "actions": [
    {
      "appointment_info": {}
    }
  ]
}

In the Expression Builder, I structured it as follows:

@(entity_id=entity_id,
  link_id=link_id,
  url=url,
  actions=[@(appointment_info=@())])

However, I receive an error at the line actions=[@(appointment_info=@())], specifically at @() right after appointment_info=. This should work, but it's still showing an error in ADF, and I'm unable to structure it as intended:

"actions": [
  {
    "appointment_info": {}
  }
]

Can someone help me understand what I'm doing wrong and how to correctly format this JSON structure in ADF's Expression Builder? Any guidance would be greatly appreciated.


Solution

  • In the Expression Builder, I structured it as follows:

    @(entity_id=value1,
        link_id=value2,
        url=value3,
        actions=[@(appointment_info=@(appointment_null=appointment_null))])
    

    I added a new column in the source's select query and fetched a null value. Since the column has null for all rows, it will always display as {}. However, this won't work for an empty string.

    select '' appointment_empty, null appointment_null from .........

    appointment_empty would display the column name and appointment_null would'nt.