I am fairly new to Avro schemas, and I am aware that a union can be used to allow multiple types e.g:
"message": ["null", "string"]
However, I am having an issue when the passed json value is a string. e.g:
"message": "Hello World!"
The error I am getting is:
failed to convert json to avro expected start-union. got value_string
I have seen the answer here https://stackoverflow.com/a/27499930/5481419, where it is stated that you must encode the JSON like so:
"message": {"string": "Hello World!"}
However, this is not possible for me, as the JSON that is getting mapped by the Avro schema is a response from an external endpoint, and it just returns a string as the value (It can also return null, hence why I need the union). Is there any other way around this? I am also required to use Avro schemas here.