Hi - a quick question about Couchbase Lite .NET. I did quite a bit of
searching and couldn't find any information about this, so here goes:
I have the following document in my database with id "myDoc":
{
"nestedObject": {
"name": "Nesty",
"someProperty": true
},
"someArray": [
"Red", "Green", "Blue"
]
}
Here's my code:
// Get the database and document
var database = Manager.SharedInstance.GetDatabase("myDatabase");
var doc = database.GetDocument("myDoc");
// Get the property and write its type to Console
var property = doc.GetProperty("nestedObject");
Console.WriteLine(property.GetType().AssemblyQualifiedName); // Returns
Newtonsoft.Json.Linq.JObject??
I would have expected to get back an IDictionary<string, object> from
GetProperty when accessing the nested object. So now if want to get at
'someProperty' I have to do this:
var property = (JObject)doc.GetProperty("nestedObject");
var someProperty = (bool)property["someProperty"];
Similarly, look at this code:
var property = doc.GetProperty("someArray");
Console.WriteLine(property.GetType().AssemblyQualifiedName); // Returns
Newtonsoft.Json.Linq.JArray??
Is this the intended behavior, or am I missing something? I actually think
this is kind of cool, because the Json.NET's LINQ-to-JSON API is really
cool. I really wish you could do this:
JObject docObject = doc.ToJObject(); // Or something similar
So anyway, my main question here is: If I rely on these underlying
Json.NET objects, will they be pulled out from under me at some point in
the future, or is this the way it will stay?
--
You received this message because you are subscribed to the Google Groups
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/mobile-couchbase/0898e883-be75-467e-9cfc-e9a224f69b43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.