Namespace: DeltaEngine.Content.Json
Assembly: DeltaEngine.Content.Json (in DeltaEngine.Content.Json.dll) Version: 1.1.1.0 (1.1.1)
Tests: DeltaEngine.Content.Json.Tests.JsonNodeTests
6 unit tests call DeltaEngine.Content.Json.JsonNode.NumberOfNodes
Assembly: DeltaEngine.Content.Json (in DeltaEngine.Content.Json.dll) Version: 1.1.1.0 (1.1.1)
Syntax
Property Value
Type: Int32Remarks
Examples
[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 EmptyJsonShouldHaveZeroNodes() { var json = new JsonNode("{}"); Assert.AreEqual(0, json.NumberOfNodes); }
See Also