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

Commit 6042325

Browse files
committed
Add JsonObject string List tests
1 parent 1be55ef commit 6042325

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/ServiceStack.Text.Tests/JsonObjectTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,5 +309,24 @@ public void Can_deserialize_array_objects_in_Map()
309309
new TestJArray { Id = 2, Name = "Role 2" },
310310
}));
311311
}
312+
313+
[Test]
314+
public void Can_deserialice_string_list()
315+
{
316+
var obj = new JsonObject {
317+
["null"] = null,
318+
["item"] = "foo",
319+
["list"] = new List<string> { "foo", "bar", "qux" }.ToJson()
320+
};
321+
322+
var nullList = obj["null"].FromJson<List<string>>();
323+
var itemList = obj["item"].FromJson<List<string>>();
324+
var listList = obj["list"].FromJson<List<string>>();
325+
326+
Assert.That(nullList, Is.Null);
327+
Assert.That(itemList, Is.EquivalentTo(new[]{ "foo" }));
328+
Assert.That(listList, Is.EquivalentTo(new[]{ "foo", "bar", "qux" }));
329+
}
330+
312331
}
313332
}

0 commit comments

Comments
 (0)