Newtonsoft.Json 中 JsonTextReader

string json = @"{ 'CPU': 'Intel', 'PSU': '500W', 'Drives': [ 'DVD read/writer' /*(broken)*/, '500 gigabyte hard drive', '200 gigabyte hard drive' ] }"; JsonTextReader reader = new JsonTextReader(new StringReader(json)); while (reader.Read()) { if (reader.Value != null) { Console.WriteLine("Token: {0}, Value: {1}", reader.TokenType, reader.Value); } else { Console.WriteLine("Token: {0}", reader.TokenType); } } // Token: StartObject // Token: PropertyName, Value: CPU // Token: String, Value: Intel // Token: PropertyName, Value: PSU // Token: String, Value: 500W // Token: PropertyName, Value: Drives // Token: StartArray // Token: String, Value: DVD read/writer // Token: Comment, Value: (broken) // Token: String, Value: 500 gigabyte hard drive // Token: String, Value: 200 gigabyte hard drive // Token: EndArray // Token: EndObject

转载于:https://www.cnblogs.com/lyjpy456/p/11465463.html

你可能感兴趣的:(Newtonsoft.Json 中 JsonTextReader)