Skip to content

Commit fd44b2c

Browse files
Update README.md
1 parent e3632db commit fd44b2c

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,36 @@ with an earlier "throw away" deserialization.
5050

5151
Jil currently **does not** support dynamic deserialization.
5252

53+
### Dynamic Deserialization
54+
55+
```
56+
using(var input = new StringReader(myString))
57+
{
58+
var result = JSON.DeserializeDynamic(input);
59+
}
60+
```
61+
62+
There is also a `DeserializeDynamic` method that works directly on strings.
63+
64+
These methods return `dynamic`, and support the following operations:
65+
66+
- Casts
67+
* ie. `(int)JSON.DeserializeDynamic("123")`
68+
- Member access
69+
* ie. `JSON.DeserializeDynamic(@"{""A"":123}").A`
70+
- Indexers
71+
* ie. `JSON.DeserializeDynamic(@"{""A"":123}")["A"]`
72+
* or `JSON.DeserializeDynamic("[0, 1, 2]")[0]`
73+
- Foreach loops
74+
* ie. `foreach(var keyValue in JSON.DeserializeDynamic(@"{""A"":123}")) { ... }`
75+
- in this example, `keyValue` is a dynamic with `Key` and `Value` properties
76+
* or `foreach(var item in JSON.DeserializeDynamic("[0, 1, 2]")) { ... }`
77+
- in this example, `item` is a `dynamic` and will have values 0, 1, and 2
78+
- Common unary operators (+, -, and !)
79+
- Common binary operators (&&, ||, +, -, *, /, ==, !=, <, <=, >, and >=)
80+
- `.Length` & `.Count` on arrays
81+
- `.ContainsKey(string)` on objects
82+
5383
## Supported Types
5484

5585
Jil will only (de)serialize types that can be reasonably represented as [JSON](http://json.org).

0 commit comments

Comments
 (0)