Skip to content

Are nested structs supported? #62

Answered by Oudwins
GustavoOS asked this question in Q&A
Discussion options

You must be logged in to vote

In fact, this should be very close in Zog:

var zContact = z.Struct(z.Schema{
    "email": z.String().Email(),
    "name": z.String()
})

var zForm = z.Struct({
    "command": z.enum(["send_email"]),
    "sender": zContact,
    "receiver": zContact
})

type Form struct {
  Command string
  Sender Contact
  Receiver Contact
}
var formData Form
zForm.parse(zjson.Decode(jsonData), &formData)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Oudwins
Comment options

Answer selected by Oudwins
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants