| 1 | import x.json2 |
| 2 | import time |
| 3 | |
| 4 | struct Person { |
| 5 | mut: |
| 6 | name string |
| 7 | age ?int = 20 |
| 8 | birthday time.Time |
| 9 | deathday ?time.Time |
| 10 | } |
| 11 | |
| 12 | fn test_main() { |
| 13 | resp := '{"name": "Bob", "age": 20, "birthday": "2025-10-12 10:14:52"}' |
| 14 | person := json2.decode[Person](resp)! |
| 15 | assert '${person}' == "Person{ |
| 16 | name: 'Bob' |
| 17 | age: Option(20) |
| 18 | birthday: 2025-10-12 10:14:52 |
| 19 | deathday: Option(none) |
| 20 | }" |
| 21 | } |
| 22 |