I am trying to use the webclient module to query the couchDB rest interface (I am using it instead of the opa couchdb api because I need to get a specific number of documents).
Here is the code used to make the query:
listmydocs(dburi)=
match WebClient.Get.try_get(dburi) with
| { failure = _ } -> print("error\n")
| {success=s} -> match WebClient.Result.get_class(s) with
| {success} -> print("{s.content}")
| _ -> print("Error {s.code}")
end
the result given in s.content is the following string:
{"total_rows":177,"offset":0,"rows":[
{"id":"87dc6b6d9898eff09b1c8602fb00099b","key":"87dc6b6d9898eff09b1c8602fb00099b","value":{"rev":"1-853bd502e3d80d08340f72386a37f13a"}},
{"id":"87dc6b6d9898eff09b1c8602fb000f17","key":"87dc6b6d9898eff09b1c8602fb000f17","value":{"rev":"1-4cb464c6e1b773b9004ad28505a17543"}}
]}
I was wondering what would be the best approach to parse this string to get for example the list of ids, or only the rows field? I tried to use Json.deserialize(s.content) but not sure where to go from there.