{
"dnaSequences": [
{
"id": "seq_fdfdfd",
"fields": {
"ORF": [
"seq_aaaaaa",
"seq_bbbbbbbb",
"seq_ccccccccc",
"seq_ddddddddd"
]
},
"isCircular": false,
"schemaId": "ts_fdfdf"
}
]
}
I'm trying to create this JSON above with the FOR JSON PATH in SQL Server...
This is the query so far...but i cant seem to get the double quotes correct around the nested objects in the ORF array? Also the values in the ORF are comping from one field in multiple records.
SELECT top 1 id,
(SELECT top 3 orf_seq_xxx AS 'fields.ORF'
FROM vw_viewName
FOR JSON PATH) AS ORF,
[isCircular],
[schemaId]
FROM vw_viewNameFOR JSON PATH, ROOT('dnaSequences');
field: orf_seq_xxx is created in a sql view by concatenating data together..
SUBSTRING((SELECT top 5 ',' + 'seq_aaaaa_' AS 'data()'FROM [v_viewName] FOR XML PATH('')), 2 , 9999)As orf_seq_xxx
you can ignore the top 5 and the top 3 in the sql...I only have this to limit the amount of data..