需要先引用 Newtonsoft.Json.dll
1 2 3 4 5 6 7 8 9
| public void Test_json() { string a = "{\"input\":{\"size\":193156,\"type\":\"image/png\"},\"output\":{\"size\":59646,\"type\":\"image/png\",\"width\":487,\"height\":284,\"ratio\":0.3088,\"url\":\"https://api.tinify.com/output/hrqtghqtv0ab4qgv.png\"}}"; Newtonsoft.Json.Linq.JObject jobject = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(a); string input_size = Convert.ToString(jobject["output"]); Console.WriteLine(input_size); }
|