Here is the table definition:
key_en, text_en, html_text_en, key_fr, text_fr, html_text_fr
Here is my query:
SELECT
[key_en] AS 'en.key'
,[text_en] AS 'en.text'
,[html_text_en] AS 'en.htmltext'
,[key_fr] AS 'fr.key'
,[text_fr] AS 'fr.text'
,[html_text_fr] AS 'fr.htmltext'
FROM [MyContent]
FOR JSON PATH;
The result I get as JSON is correct.
[
{
"en": {
"key": "key en",
"text": "text en",
"htmltext": "html en"
},
"fr": {
"key": "key fr",
"text": "text fr",
"htmltext": "html fr"
}
},
{
"en": {
"key": "key2 en",
"text": "text2 en",
"htmltext": "html2 en"
},
"fr": {
"key": "key2 fr",
"text": "text2 fr",
"htmltext": "html2 fr"
}
}
]
However the result set is in a single row (very long string).
I'd like to spread the result set across as many rows as the data in the table. The expected result should be:
ROW 1
{
"en": {
"key": "key en",
"text": "text en",
"htmltext": "html en"
},
"fr": {
"key": "key fr",
"text": "text fr",
"htmltext": "html fr"
}
}
ROW 2
{
"en": {
"key": "key2 en",
"text": "text2 en",
"htmltext": "html2 en"
},
"fr": {
"key": "key2 fr",
"text": "text2 fr",
"htmltext": "html2 fr"
}
}
What changes do I have to bring to reach my goal?
FOR JSON PATH, WITHOUT_ARRAY_WRAPPERwill help. I think that the answers are correct.