Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit d9e6a3e

Browse files
committed
Add JsonObject example
1 parent 5e4ff82 commit d9e6a3e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tests/ServiceStack.Text.Tests/JsonObjectTests.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using NUnit.Framework;
1+
using System.Linq;
2+
using NUnit.Framework;
23

34
namespace ServiceStack.Text.Tests
45
{
@@ -113,5 +114,19 @@ public void Can_deserialize_JsonArray()
113114

114115
Assert.That(proj3Name, Is.EqualTo("Project3"));
115116
}
117+
118+
[Test]
119+
public void Can_deserialize_JSON_Object()
120+
{
121+
var json = "{\"http://SomeUrl.com/\":{\"http://otherUrl.org/schema#name\":[{\"value\":\"val1\",\"type\":\"val2\"}]}}";
122+
123+
var obj = JsonObject.Parse(json)
124+
.Object("http://SomeUrl.com/");
125+
126+
var items = obj.ArrayObjects("http://otherUrl.org/schema#name")[0];
127+
128+
Assert.That(items["value"], Is.EqualTo("val1"));
129+
Assert.That(items["type"], Is.EqualTo("val2"));
130+
}
116131
}
117132
}

0 commit comments

Comments
 (0)