couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brad King" <>
Subject Json.Net and couchbrowse
Date Thu, 19 Jun 2008 14:17:34 GMT
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.

Using 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 if anyone else would like it, let me know.

View raw message