Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I don't know about JSON.NET, but it works fine with <code>JavaScriptSerializer</code> from <code>System.Web.Extensions.dll</code> (.NET 3.5 SP1):</p> <pre><code>using System.Collections.Generic; using System.Web.Script.Serialization; public class NameTypePair { public string OBJECT_NAME { get; set; } public string OBJECT_TYPE { get; set; } } public enum PositionType { none, point } public class Ref { public int id { get; set; } } public class SubObject { public NameTypePair attributes { get; set; } public Position position { get; set; } } public class Position { public int x { get; set; } public int y { get; set; } } public class Foo { public Foo() { objects = new List&lt;SubObject&gt;(); } public string displayFieldName { get; set; } public NameTypePair fieldAliases { get; set; } public PositionType positionType { get; set; } public Ref reference { get; set; } public List&lt;SubObject&gt; objects { get; set; } } static class Program { const string json = @"{ ""displayFieldName"" : ""OBJECT_NAME"", ""fieldAliases"" : { ""OBJECT_NAME"" : ""OBJECT_NAME"", ""OBJECT_TYPE"" : ""OBJECT_TYPE"" }, ""positionType"" : ""point"", ""reference"" : { ""id"" : 1111 }, ""objects"" : [ { ""attributes"" : { ""OBJECT_NAME"" : ""test name"", ""OBJECT_TYPE"" : ""test type"" }, ""position"" : { ""x"" : 5, ""y"" : 7 } } ] }"; static void Main() { JavaScriptSerializer ser = new JavaScriptSerializer(); Foo foo = ser.Deserialize&lt;Foo&gt;(json); } } </code></pre> <p><strong>Edit:</strong></p> <p>Json.NET works using the same JSON and classes.</p> <pre><code>Foo foo = JsonConvert.DeserializeObject&lt;Foo&gt;(json); </code></pre> <p>Link: <a href="http://james.newtonking.com/projects/json/help/index.html?topic=html/SerializingJSON.htm" rel="noreferrer">Serializing and Deserializing JSON with Json.NET</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload