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

Commit b82ac1e

Browse files
committed
Add ParseJson example
1 parent 7ad1dc2 commit b82ac1e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/ServiceStack.Text.Tests/StringConverterUtilsTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,23 @@ public void Create_from_StringEnumerable()
8888
Assert.That(result, Is.EquivalentTo(value.Items));
8989
}
9090

91+
public class ParseFoo
92+
{
93+
public string A { get; set; }
94+
95+
public static ParseFoo ParseJson(string json)
96+
{
97+
var obj = JsonObject.Parse(json);
98+
var to = new ParseFoo { A = obj["B"] };
99+
return to;
100+
}
101+
}
102+
103+
[Test]
104+
public void Does_call_ParseJson_static_method()
105+
{
106+
var foo = "{\"B\":\"Value\"}".FromJson<ParseFoo>();
107+
Assert.That(foo.A, Is.EqualTo("Value"));
108+
}
91109
}
92110
}

0 commit comments

Comments
 (0)