We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have next code:
package main import ( "log" "github.com/linkedin/goavro/v2" ) const schema = `{ "type": "record", "name": "Payload", "fields": [ { "name": "image", "default": "null", "type": [ "null", { "type": "record", "name": "Image", "fields": [ { "name": "url", "type": "string" }, { "name": "caption", "type": "string", "default": "undefined" } ] } ] } ] } ` func main() { codec, err := goavro.NewCodec(schema) if err != nil { println("schema is wrong") log.Fatalln(err) } str := `{"image": {"caption": "asd"}}` a, b, err := codec.NativeFromTextual([]byte(str)) if err != nil { println(err.Error()) } else { println(string(b)) println(a) } }
Image is optional field: it could be null or contain some fields (url and caption).
Instead of successful parsing of JSON i receving next error message: cannot decode textual record "SendPayload": cannot decode textual union: cannot decode textual map: cannot determine codec: "caption" for key: "image".
cannot decode textual record "SendPayload": cannot decode textual union: cannot decode textual map: cannot determine codec: "caption" for key: "image"
Problem is that avro schema contains image.caption field. I tried sending image with caption, url and both, but problem persists.
image.caption
The text was updated successfully, but these errors were encountered:
This works:
str := `{"image": { "Image" : {"caption": "asd", "url": "URL"}}}`
When using union type, target type should be specified
Sorry, something went wrong.
No branches or pull requests
I have next code:
Image is optional field: it could be null or contain some fields (url and caption).
Instead of successful parsing of JSON i receving next error message:
cannot decode textual record "SendPayload": cannot decode textual union: cannot decode textual map: cannot determine codec: "caption" for key: "image"
.Problem is that avro schema contains
image.caption
field. I tried sending image with caption, url and both, but problem persists.The text was updated successfully, but these errors were encountered: