| 1 | import json |
| 2 | |
| 3 | struct Test { |
| 4 | optional_string ?string |
| 5 | optional_array ?[]string |
| 6 | optional_struct_array ?[]string |
| 7 | optional_map ?map[string]string |
| 8 | } |
| 9 | |
| 10 | fn test_main() { |
| 11 | test := Test{} |
| 12 | encoded := json.encode(test) |
| 13 | assert dump(encoded) == '{}' |
| 14 | |
| 15 | test2 := Test{ |
| 16 | optional_map: { |
| 17 | 'foo': 'bar' |
| 18 | } |
| 19 | } |
| 20 | encoded2 := json.encode(test2) |
| 21 | assert dump(encoded2) == '{"optional_map":{"foo":"bar"}}' |
| 22 | } |
| 23 |