Wednesday, October 31, 2012

CouchBase 2.0 beta - Binary instead of JSON when storing data in ASP.NET [SOLVED]

Right now I am working with CouchBase and ASP.NET. CouchBase in my opinion is one of the best NoSQL solutions out there, and I've checked quite a few. The problem is that getting answers to questions is very hard, the forum has very little movement there, and even asking questions on stackoverflow doesn't yield fast answers.


Still, I prefer CouchBase over MongoDB for many reasons. Now for my question.  It's a newbie question. When I put a simple string into a bucket and view it in the CouchBase administrator user interface, I only see a binary representation of the data and not JSON ad I supposed to see. I am using CouchBase 2.0 beta.

I've asked this question on CouchBase forum and still haven't for an answer. Here's a sample code:


 var client = new CouchbaseClient();

client.Store(StoreMode.Add, "key", "sample_data");


What I am getting

So what am I doing wrong here. This suppose to be the most basic way to insert data into a bucket in CouchBase.  I've tried also putting a JSON equivalent value, but it doesn't work. IF you know why do I get to see a binary data instead of JSON, I will be glad to hear.

Thanks.

Solution:

You need to provide the Store function a JSON string. I provided a simple string and therefore the data was written in binary format. You can use the built in .NET JSON serializer or JSON.NET and it will wor for you.



No comments:

Post a Comment