JsonNode GetIntArray Method Delta Engine Documentation

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

public int[] GetIntArray()

Return Value

Type:  Int32 
Remarks

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

2 unit tests call DeltaEngine.Content.Json.JsonNode.GetIntArray
[Test]
public void ReadArrayData()
{
    var json = new JsonNode("{ \"arrayData\":[1, 2, 3] }");
    Assert.AreEqual(1, json.NumberOfNodes);
    Assert.AreEqual(new[] { 1, 2, 3 }, json["arrayData"].GetIntArray());
}
[Test]
public void ReadJsonArray()
{
    var json = new JsonNode("{ \"layers\":[ { \"sky\":[1, 1] }, { \"ground\":[0, 0] } ] }");
    Assert.AreEqual(1, json.NumberOfNodes);
    var layers = json["layers"];
    Assert.AreEqual(2, layers.NumberOfNodes);
    Assert.AreEqual(new[] { 1, 1 }, layers[0]["sky"].GetIntArray());
    Assert.AreEqual(new[] { 0, 0 }, layers[1]["ground"].GetIntArray());
}
See Also