There are a lot of questions and answers on stackoverflow on the subject, but no one that helps.
I have a schema with optional value:
{
\"type\" : \"rec
case 1 is working fine in java .
{
"username" : "2271AE67-34DE-4B43-8839-07216C5D10E1",
"errorData" : { "string":"070226AC-9B91-47CE-85FE-15AA17972298"}
}
for case 2 Your schema is defined for union. You can update you schema as below to deserialize json.
{
"username" : "2271AE67-34DE-4B43-8839-07216C5D10E1",
"errorData" : "070226AC-9B91-47CE-85FE-15AA17972298"
}
{
"type" : "record",
"name" : "UserSessionEvent",
"namespace" : "events",
"fields" : [ {
"name" : "username",
"type" : "string"
}, {
"name" : "errorData",
"type" : "string" ,
"default" : null
}]
}