| 1 | import json |
| 2 | |
| 3 | pub struct SomeStruct { |
| 4 | pub mut: |
| 5 | test ?string |
| 6 | } |
| 7 | |
| 8 | pub struct MyStruct { |
| 9 | pub mut: |
| 10 | result ?SomeStruct |
| 11 | id string |
| 12 | } |
| 13 | |
| 14 | fn test_main() { |
| 15 | a := MyStruct{ |
| 16 | id: 'some id' |
| 17 | result: SomeStruct{} |
| 18 | } |
| 19 | encoded_string := json.encode(a) |
| 20 | assert encoded_string == '{"result":{},"id":"some id"}' |
| 21 | test := json.decode(MyStruct, encoded_string)! |
| 22 | assert test == a |
| 23 | } |
| 24 |