Does anyone know how to save a JSON string in a DocumentDB collection?

I am trying to make the NLog DocumentDB quick and dirty target, but it seems I can not directly store the JSON in DocumentDB.

Using the C # library, it seems that the DocumentClient.CreateDocumentAsync () parameter of the document requires only a "complex type", and I do not see other methods that can accept a JSON string.

Has anyone else figured out how to save JSON directly?

+5
source share
1 answer

Here is an example of how you can save a JSON string using DocumentDB using the C # SDK.

using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(@"{ a : 5, b: 6, c: 7 }"))) { await client.CreateDocumentAsync(collectionSelfLink, Document.LoadFrom<Document>(ms)); } 
+10
source

Source: https://habr.com/ru/post/1216121/


All Articles