- string test_json = "{\"name\":\"tom\",\"nickname\":\"tony\",\"sex\":\"male\",\"age\":20,\"email\":\"123@123.com\"}";
- var o = JObject.Parse(yourJsonString);
- foreach (JToken child in o.Children())
- {
- var property1 = child as JProperty;
- MessageBox.Show(property1.Name + ":" + property1.Value);
- }
多层Json
- var o = JObject.Parse(yourJsonString);
- foreach (JToken child in o.Children())
- {
- //var property1 = child as JProperty;
- //MessageBox.Show(property1.Name + ":" + property1.Value);
- foreach (JToken grandChild in child)
- {
- foreach (JToken grandGrandChild in grandChild)
- {
- var property = grandGrandChild as JProperty;
- if (property != null)
- {
- MessageBox.Show(property.Name + ":" + property.Value);
- }
- }
- }
- }