JsonNode ClassDelta Engine Documentation
Provides json text parsing support without having to include Newtonsoft Json yourself and making it work on different platforms easily replacing functionality (like Content.Xml). View code on GitHub
Inheritance Hierarchy

System Object
  DeltaEngine.Content.Json JsonNode

Namespace: DeltaEngine.Content.Json
Assembly: DeltaEngine.Content.Json (in DeltaEngine.Content.Json.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class JsonNode

The JsonNode type exposes the following members.

Constructors

  NameDescription
Public methodJsonNode
Initializes a new instance of the JsonNode class
Top
Methods

  NameDescription
Public methodGet T 
Public methodGetIntArray
Public methodGetOrDefault T 
Public methodToString (Overrides Object ToString .)
Top
Properties

  NameDescription
Public propertyItem Int32 
Public propertyItem String 
Public propertyNumberOfNodes
Top
Remarks

Tests: DeltaEngine.Content.Json.Tests.JsonNodeTests
Examples

9 unit tests call DeltaEngine.Content.Json.JsonNode
[Test]
public void ReadJsonWithChildrenNodes()
{
    var json = new JsonNode("{ \"Child1\": { \"Number\":1 }, \"Child2\": { \"Number\":2 } }");
    Assert.AreEqual(2, json.NumberOfNodes);
    Assert.AreEqual(1, json["Child1"].Get<int>("Number"));
    Assert.AreEqual(2, json["Child2"].Get<int>("Number"));
}
[Test]
public void ParseBooleansStringsAndNumbers()
{
    var json = new JsonNode("{ \"Flag\": true, \"SomeNumber\": 1.23, \"Text\": \"blub\" }");
    Assert.AreEqual(3, json.NumberOfNodes);
    Assert.IsTrue(json.Get<bool>("Flag"));
    Assert.AreEqual(1.23f, json.Get<float>("SomeNumber"));
    Assert.AreEqual("blub", json.GetOrDefault("Text", ""));
}
[Test]
public void ParseEmptyJsonTextIsNotAllowed()
{
    Assert.Throws<JsonNode.NeedValidText>(() => new JsonNode(""));
}
See Also