Handling string as JSON

Hi,

In SDK 1.3 we were capable of creating our own custom JSON string, storing it as a string and having Couchbase handle it as JSON. Is still possible with the .NET 2.0 SDK? It seems like the new generic methods will no longer allow this and basically handle the string as a string rather than JSON.

@RentierM -

I am not sure I exactly understand what you mean, for example:

       using (var bucket = _cluster.OpenBucket())
        {
            var jsonString = "{\"name\":\"bar\", \"age\":10}";
            var insert = bucket.Upsert("JSON_KEY", jsonString);
            Assert.IsTrue(insert.Success);

            var get = bucket.Get<string>("JSON_KEY");
            Assert.IsTrue(get.Success);
            Assert.AreEqual(jsonString, get.Value);
        }

This code creates a JSON string and stores it in Couchbase and then retrieves it comparing it to the original. If I look the key up in the Couchbase Admin Console, this is what I see:

I think this is the behavior expected as you described in your question?

-Jeff

Yes, that does work. Just went down a rabbit hole due to a couple of other changes between the old and new SDK, but this does work. Thanks.

@RentierM -

Good to hear. Yes, the new SDK is a complete rewrite, so quite a bit has changed. Some things that were layered on top of the older SDK are embedded in the new SDK, JSON support is one of those things.

Thanks,

Jeff