I'm trying to generate a JSON file based on Avro schema using Java.
This is the Avro that is parsing generated JSON file:
{
"namespace": "com.abc.schemas",
"type": "record",
"name": "Event",
"fields": [
{"name": "customer", "type": "string"},
{"name": "signature", "type": [null, "bytes"], "default": null},
{"name": "context", "type": [null, {"type": "map", "values": "string"}]}
]
}
I read Avro documentation and ask google many times but still, I have no idea how to create data that will be valid for those two types: Union and Map.
private JSONObject objectFiller(JSONObject json) throws UnsupportedEncodingException {
json.put("customer", "AnyStringForTest");
json.put("signature", ???????Avro Union bytes type?????);
json.put("context", ????????Avro Map type??????);
......
Does anyone have any ideas?