You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Brad King <br...@gmail.com> on 2008/06/19 16:17:34 UTC

Json.Net and couchbrowse

If you happen to be working in c#, you might want to check out
James-Newton Kings Json.Net library. It seems more robust than LitJson
used in CouchBrowse, and supports LINQ queries. It does an excellent
job serializing .Net types, and exposes good controls over
serialization hangups like dealing with nulls.

http://james.newtonking.com/pages/json-net.aspx

Using Json.net linq syntax simplifies (relatively) parsing some of the
result structures in couchbrows into .Net objects:

public DocInfo[] GetAllDocuments(string server,string db)
{
  string result=DoRequest(server+"/"+db+"/_all_docs","GET");
  JObject o = JObject.Parse(result);
  var docs =
                from p in o["rows"].Children()
                select new DocInfo { ID = p.Value<string>("id"),
Revision = p["value"].Value<string>("rev") };

  return docs.ToArray<DocInfo>();
}

In general, the c# couchbrowse package appears to be out of date, but
its a decent starting point. I've got the modified base I/O converted
to json.net if anyone else would like it, let me know.