Files
Newtonsoft.Json/Src/Newtonsoft.Json.Tests/Documentation/Examples/Linq/CreateReader.cs
T
James Newton-King 68eacc480b -JSON Schema fixes
-Fixed static values being included with fields serialization
-Examples! (work in progress)
2013-01-23 21:39:54 +13:00

49 lines
994 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Linq;
namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
{
public class CreateReader
{
public void Example()
{
JObject o = new JObject
{
{"Cpu", "Intel"},
{"Memory", 32},
{
"Drives", new JArray
{
"DVD",
"SSD"
}
}
};
JsonReader reader = o.CreateReader();
while (reader.Read())
{
Console.Write(reader.TokenType);
if (reader.Value != null)
Console.Write(" - " + reader.Value);
Console.WriteLine();
}
// StartObject
// PropertyName - Cpu
// String - Intel
// PropertyName - Memory
// Integer - 32
// PropertyName - Drives
// StartArray
// String - DVD
// String - SSD
// EndArray
// EndObject
}
}
}