I’m a beginner with mongoDb, I would like to access MongoDb rest service, the data I retrieved is json type. My question is, how do you parse this data ? I don’t find any MongoDb api which allows me to query it easily. So what would you do ?
Here’s an example of the data, I queried the key “Name” which returned me on row thanks to this url:
http://localhost:28017/MyDatabase/MyCollection/?filter_Key=Name
{
“offset” : 0,
“rows”: [
{ “_id” : { “$binary” : “fXvnbtlMhU24EWg9NiY5QQ==”, “$type” : “03” }, “Key” : “Name”, “Value” : “John Smith” }
],
“total_rows” : 1 ,
“query” : { “Key” : “Name” } ,
“millis” : 0
}
And I would like to retrieve the Value “John Smith”
Thank’s
[EDIT]
I’ve managed to get {“Value”: “John Smith”} out of my json. oh!! See this ugly code:
var urlToFetch = "http://`localhost`:28017/MyDatabase/MyCollection/?filter_Key=Name";
var jsonData = GetDataFrom(urlToFetch);
var value = JsonConvert.DeserializeObject(jsonData);
foreach (var key in ((JObject)value)["rows"].Values())
{
key.Parent.Last;
}
It’s not perfect, I still don’t get my John Smith But there’re must be a better way without manually parsing, aren’t there ?
Here the solution guys: