c# 4.0 - How to get filepath value from the Json -
i have json file given below
var json={ "attachmentinfo":[ { "filename":"sign_encrypted_.pdf", "filepath":"b89ddfa7-af16-4e4d-b16b-b6d49db9b91f", "filesize":104504.0, "fileextention":".pdf", "filetype":2 } ] }
i need filepath above json.
i tried
var filepath=(string)json["attachmentinfo"].selecttoken("filepath");
but null value return.
thanks in advance help.
first, try deserialize json , can access dynamic object, here snipe code:
string json = ...; var serializer = new javascriptserializer(); serializer.registerconverters(new[] { new dynamicjsonconverter() }); dynamic obj = serializer.deserialize(json, typeof(object)); var filepath = obj.attachmentinfo[0].filepath;
Comments
Post a Comment