c# - Getting specific value from specific key of Document inside document -
i have document this
{ "_id": { "$oid" : "51776bca40bcc60038000001" }, "username": "domi55", "password": "test", "character": { "job": "warrior", "level": 1, "skill": { "skillid": "1001", "skillname": "blade dance", "levelrequirment": 1 } } } }
how "job" value , "skillname" value in c#? i'm using mongodb , mongodb c# driver
using json.net
dynamic obj = jsonconvert.deserializeobject(yourdoc); console.writeline("{0} {1}", obj.character.job, obj.character.skill.skillname);
or using javascriptserializer
var obj = new javascriptserializer().deserialize<dynamic>(json); console.writeline("{0} {1}",obj["character"]["job"],obj["character"]["skill"]["skillname"]);