I need help in transforming a string to json to put the values in separated lines. Using tsql (2019)
How do I have to transform the provided data (payload) into a json to create the expected result or is there another way to splitt the data?
Thank you in advanced.
AS for the main keys it works but I would like to have the interests in separated lines as well current result:
CustomerID | payload | payload_json | key | value |
---|---|---|---|---|
10001 | {diet:[vegetarian],interest:[cooking,fitness,technology,interior,diy,talk,gaming,fashion]} | {"diet":["vegetarian"],"interest":["cooking","fitness","technology","interior","diy","talk","gaming","fashion"]} | diet | vegetarian |
10001 | {diet:[vegetarian],interest:[cooking,fitness,technology,interior,diy,talk,gaming,fashion]} | {"diet":["vegetarian"],"interest":["cooking","fitness","technology","interior","diy","talk","gaming","fashion"]} | interest | ["cooking","fitness","technology","interior","diy","talk","gaming","fashion"] |
Expected Result:
CustomerID | Key | Value |
---|---|---|
10001 | diet | vegetarian |
10001 | interest | Cooking |
10001 | interest | fitness |
10001 | interest | technology |
. | ||
. | ||
. |