Need to flatten json array in azure-cosmos db

Viewed 1041

I have simple JSON

{"ProductUID":1100,"Color":"White","tags":["toy","children","games"]}

I want output as

[
    {
        "ProductUID": 1100,
        "Color":"White",
        "tags":"toy"
    },
    {
        "ProductUID": 1100
         "Color" : "White",
         "tags" : "Children"
    },
    {
        "ProductUID": 1100,
        "Color": "White",
        "tags": "games"
    }
]

I have tried this query in cosmos db but couldn't separate tags array

SELECT  P.ProductUID, P.tags
FROM Products P
join C in P.tags
1 Answers

Welcome to StackOverflow!

This query should project what you need:

SELECT  P.ProductUID, P.Color, C AS tags
FROM Products P
join C in P.tags
Related