首页 > 代码库 > Json字符串转Dictionary

Json字符串转Dictionary

  /// <summary>
    /// json字符串转Dictionary
    /// </summary>
    /// <param name="json"></param>
    /// <returns></returns>
    public static Dictionary<string, object> getValue(string json)
    {
        //解析json对象
        JavaScriptSerializer serializer = new JavaScriptSerializer();
        return (Dictionary<string, object>)serializer.DeserializeObject(json);
    }

object url;
获取json其中一个值:getValue(payJson).TryGetValue("字段名", out url).ToString()

Json字符串转Dictionary