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

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



Solution 1:[1]

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
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Loris Securo