Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The default deserializer for the client uses .NET's binary serializer, so when you save or read a JSON string, it's just a string. GetJson will always just return a string. However, there are a couple of options:</p> <p>You could convert JSON records to Dictionary instances:</p> <pre><code>var appJson = "{ \"UsersOnline\" : 1, \"NewestMember\" : \"zblock\" }"; var result = client.ExecuteStore(StoreMode.Set, "userCount", appJson); var item = client.GetJson&lt;Dictionary&lt;string, object&gt;&gt;("userCount"); Console.WriteLine("There are {0} users online. The newest member is {1}.", item["UsersOnline"], item["NewestMember"]); </code></pre> <p>Or you could use a dynamic ExpandoObject instance:</p> <pre><code>var appJson = "{ \"UsersOnline\" : 1, \"NewestMember\" : \"zblock\" }"; var result = client.ExecuteStore(StoreMode.Set, "userCount", appJson); dynamic item = client.GetJson&lt;ExpandoObject&gt;("userCount"); Console.WriteLine("There are {0} users online. The newest member is {1}.", item.UsersOnline, item.NewestMember); </code></pre> <p>In either case you're losing static type checking, which seems like it's OK for your purposes. In both cases you get access to the JSON properties without having to parse the JSON into a POCO though...</p> <p>Edit: I wrote a couple of extension methods that may be useful and blogged about them at <a href="http://blog.couchbase.com/moving-no-schema-stack-c-and-dynamic-types" rel="nofollow">http://blog.couchbase.com/moving-no-schema-stack-c-and-dynamic-types</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload