How to decode json fields with mixed case #11545
amichelins
started this conversation in
General
Replies: 1 comment 2 replies
-
It's in the docs... Example: last_name string [json: lastName] |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have this json from a external API
[ { "number": "674952", "createdAt": "2021-01-26 20:38:47", "updatedAt": "2021-02-18 14:51:33", "status": { "name": "status.returned" }, } ]
This fields updatedAt, createdAtgive my erros at compile time.
this is my struct:
struct Pedido { number string status Status createAt string updateAt string }
json.v:9:5: error: field name
createAt
cannot contain uppercase letters, use snake_case insteadHow to decode this fields?
Annotations are allow in vlang?
Go allows this
struct Pedido { number string status Status CreateAt string
json:"createAt"UpdateAt string
json:"updateAt"}
This
json:"createAt"
tell go that createAt field in json is map to CreateAt in the structBeta Was this translation helpful? Give feedback.
All reactions