Read JSON string as key value

前端 未结 4 2150
借酒劲吻你
借酒劲吻你 2021-02-10 14:40

I have following json:

{   
    \"serverTime\": \"2013-08-12 02:45:55,558\",
    \"data\": [
        {
            \"key1\": 1,
            \"key2\": {},
                


        
4条回答
  •  孤独总比滥情好
    2021-02-10 15:07

    If you want to do this without third party libraries then do:

    I would use the following code:

    var deserializer = new JavaScriptSerializer();
    var someObject = deserializer.DeserializeObject(json);
    
    string serverTime = someObject["serverTime"].ToString();
    Dictionary data = someObject["data"] as Dictionary;
    

    Give it a go.

    Edit: You may need to change the last line to:

    Dictionary data = someObject["data"] as Dictionary;
    

提交回复
热议问题