Thursday 15 April 2010

json - DocumentDb, how can I reduce the source to a smaller subset and output in a different shape when original document has no field names -



json - DocumentDb, how can I reduce the source to a smaller subset and output in a different shape when original document has no field names -

i have next json string received external party stored in windows azure documentdb :

{ "kind": "data", "profileinfo": { "profileid": "12345", "accountid": "12345", }, "rows": [ [ "20140925", "762" ], [ "20140926", "552" ], ] }

i want cut down source smaller subset , output in different shape.

"select * date.rows" yield's subset :

[ [ [ "20140925", "762" ], [ "20140926", "552" ], ] ]

question since don't have field names, how can modify output using "select {"date":?, "value":?} syntax mention in documentdb documentation?

http://azure.microsoft.com/en-us/documentation/articles/documentdb-sql-query/

i presume you're looking transform info this:

[ { date: 20140925, value: 762 }, { date: 20140926, value: 552 } ]

in case utilize join clause iterate through document's children (rows), , utilize value keyword pull date , value values out of queried document.

here's query used produce result above:

select value {'date': r[0], 'value': r[1]} collections c bring together r in c.rows c.kind = "data"

hopefully answers question :)

json nosql azure-documentdb

No comments:

Post a Comment