-JSON Schema fixes
-Fixed static values being included with fields serialization -Examples! (work in progress)
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
|
||||
{
|
||||
public class QueryJsonDynamic
|
||||
{
|
||||
public void Example()
|
||||
{
|
||||
string json = @"[
|
||||
{
|
||||
""Title"": ""Json.NET is awesome!"",
|
||||
""Author"": {
|
||||
""Name"": ""James Newton-King"",
|
||||
""Twitter"": ""@JamesNK"",
|
||||
""Picture"": ""/jamesnk.png""
|
||||
},
|
||||
""Date"": ""2013-01-23T19:30:00"",
|
||||
""BodyHtml"": ""<h3>Title!</h3>\r\n<p>Content!</p>""
|
||||
}
|
||||
]";
|
||||
|
||||
dynamic blogPosts = JArray.Parse(json);
|
||||
|
||||
dynamic blogPost = blogPosts[0];
|
||||
|
||||
string title = blogPost.Title;
|
||||
Console.WriteLine(title);
|
||||
// Json.NET is awesome!
|
||||
|
||||
string author = blogPost.Author.Name;
|
||||
Console.WriteLine(author);
|
||||
// James Newton-King
|
||||
|
||||
DateTime postDate = blogPost.Date;
|
||||
Console.WriteLine(postDate);
|
||||
// 23/01/2013 7:30:00 p.m.
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user