Oleksandr Smirnov
Oleksandr Smirnov
olexsmir@gmail.com refactor: use an actual parser instead of reflection..., 11 days ago
olexsmir@gmail.com refactor: use an actual parser instead of reflection..., 11 days ago
| 1 | json2go |
| 2 | ------- |
| 3 | |
| 4 | json2go provides a library and cli tool for converting json strings to go struct definitions. |
| 5 | |
| 6 | library Usage: |
| 7 | |
| 8 | // with json tags |
| 9 | code, err := json2go.Transform("User", `{"name": "Alice"}`, true) |
| 10 | |
| 11 | // without json tags |
| 12 | code, err := json2go.Transform("User", `{"name": "Alice"}`, false) |
| 13 | |
| 14 | |
| 15 | cli interface: |
| 16 | |
| 17 | go install olexsmir.xyz/json2go/cmd/json2go@latest |
| 18 | |
| 19 | echo '{"id": 1, "name": "Alice"}' | json2go |
| 20 | json2go '{"id": 1, "name": "Alice"}' |
| 21 | json2go --help |