-2

JSON が文字列になっています。JavascriptSerializer を使用してデシリアライズし、SSOID の値を見つけるにはどうすればよいですか?

{
"Addresses":  [
    {
        "Address": "123 Test Road",
        "State": "Mississippi"
    }
],
"Birthdate": "April 12 2012",
"CreateDate": "April 13 2012",
"IDs": [
    {
        "isDefault": false,
        "PurchaseID": "883"
    }
],
"Sex": "Male",
"SSOID": 23444,
"Suffix": null,
"BoardID": 4324
}
4

3 に答える 3

1

この特定のケースでは:

string s = "your json string";   
System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
var obj = js.DeserializeObject(s) as Dictionary<string,object>;
int ssoid = (int)obj["SSOID"];
于 2012-04-13T20:42:55.797 に答える
1
var js = new JavaScriptSerializer();
var deserialized = (Dictionary<string, object>) js.DeserializeObject(json);
var ssoid = (int) deserialized["SSOID"];
于 2012-04-13T20:44:14.487 に答える
0
 var SSOID = new JavaScriptSerializer()
                    .Deserialize<Dictionary<string, object>>(json)["SSOID"];

また

dynamic jObj = new JavaScriptSerializer().DeserializeObject(json);
var SSOID = jObj["SSOID"];
于 2012-04-13T20:45:10.553 に答える