Skip to content

Commit d609cc5

Browse files
committed
Update README.md
1 parent 8633ae8 commit d609cc5

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,21 @@ var elements = html.FindElements(By.TagName("div"));
4343
#### Json parser
4444

4545
```csharp
46+
//JObject
47+
var JsonString = @"{ code: '10000', msg: 'success', data:{html:'html',bookes:[{name:'book1'},{name:'book2'}]},""style"":""color: rgb(153, 153, 153);"" }";};
48+
var json = JsonString.ToJObject();
49+
json["code"].ShouldEqual(10000);
50+
json["msg"].ShouldEqual("success");
51+
json["style"].ShouldEqual("color: rgb(153, 153, 153);");
52+
json["data"]["bookes"][0]["name"].ShouldEqual("book1");
53+
54+
//Generic
55+
var json = JsonString.ToJson<Ajax>();
56+
test.Code.ShouldEqual(10000);
57+
test.Msg.ShouldEqual("success");
58+
test.Style.ShouldEqual("color: rgb(153, 153, 153);");
59+
test.Data.Html.ShouldEqual("html");
60+
test.Data.Bookes.Count.ShouldEqual(2);
61+
test.Data.Bookes[0].Name.ShouldEqual("book1");
62+
test.Data.Bookes[1].Name.ShouldEqual("book2");
4663
```

0 commit comments

Comments
 (0)