I'm trying to check if a Json string matches an Avro schema. I don't care about doing serialization of the data, just getting a bool result of isValidJson=true/false
.
I'll go with every golang library.
I've tried to write something with this goavro lib, but it didn't work for me, maybe because I'm new to go like.
Desired pseudo code:
func main() {
avroSchema :=
`{"type":"record","name":"raw","namespace":"events","fields":[{"name":"my_int","type":["null","int"],"default":null},{"name":"my_string","type":["null","string"],"default":"null"},{"name":"my_string2","type":null}]}`
jsonString := `{"my_int": 3, "my_string": "foo", "my_string2": null}`
ok ;= isValidJson(jsonString, avroSchema)
}
Any idea how to implement the isValidJson(..)
method?