JObject.Properties
时间: 2024-05-13 12:20:56 浏览: 75
Newtonsoft.Json使用总结
5星 · 资源好评率100%
JObject.Properties is a method in the Newtonsoft.Json library that returns a collection of all the properties in a JSON object. This method returns an IEnumerable<JProperty> object that can be used to iterate over all the properties in the JObject.
Here is an example usage of the JObject.Properties method:
```csharp
string json = @"{
'name': 'John Doe',
'age': 30,
'zipcode': '12345'
}";
JObject jObject = JObject.Parse(json);
foreach (JProperty property in jObject.Properties())
{
Console.WriteLine("Property Name: {0}", property.Name);
Console.WriteLine("Property Value: {0}", property.Value);
}
```
Output:
```
Property Name: name
Property Value: John Doe
Property Name: age
Property Value: 30
Property Name: zipcode
Property Value: 12345
```
阅读全文