How to combine two JSON nodes in ADF

StevenT 0 Reputation points
2024-02-21T15:41:15.42+00:00

i want to combine two json nodes (in bold below) into one complex node, using azure data factory, i am using the data flow component but struggling to transform it in regards to the below example (any help would be greatly appreciated) e.g. { "op": "add", "path": "/products/AN103", "value": { "attributes": { "product_type": "Physical", "price": 12.34 } } } into a new node 'priceInfo' e.g. priceInfo { "product_type": "Physical", "price": 12.34}

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,624 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bhargava-MSFT 31,261 Reputation points Microsoft Employee Moderator
    2024-02-21T19:41:24.4933333+00:00

    Hello StevenT,

    Can you please try the below:

    I have used two derived columns to extract the relevant fields

    In the 1st derived column: Create a new column: producttype and set the expression to: value.attributes.product_type price to: value.attributes.price

    on the second derived column: create a new colum: priceinfo and set the expression to:

    iif(isNull(price), '{"producttype": "' + producttype + '", "price": null}', '{"producttype": "' + producttype + '", "price": ' + toString(price) + '}')
    
    
    

    enter image description here

    enter image description here

    enter image description here

    I hope this helps.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.