Unable to serialize Avro schema when we have an array with null objects

681 views Asked by At

I have list of objects, out of which one object is null. When I am trying to serialize the below data, I am getting

null of string of array of union of

[object1, object2, object3, null, object4]

Schema Definition

{
    "name": "myList",
    "type": [
        "null",
        {
            "type": "array",
            "items": "string"
        }
      ],
    "default": null
}

How do we allow or ignore the null in the list/array and avoid the error ? TIA

1

There are 1 answers

1
Loris Securo On

Maybe you need to also add null as a possible value in the array?

{
    "name": "myList",
    "type": [
        "null",
        {
            "type": "array",
            "items": [
              "null",
              "string"
            ]
        }
      ],
    "default": null
}