0

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

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Kamal Chanda
  • 163
  • 2
  • 12
  • What do you mean "ignore the null"? You can simply check null values before you append to the list in your client code before you serialize the data – OneCricketeer Apr 22 '22 at 16:15

1 Answers1

0

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
}
Loris Securo
  • 7,538
  • 2
  • 17
  • 28
  • Thanks for the suggestion. Tried this but it's breaking the backward compatibility with the previous schema versions. Unless it don't break that, we are not registering the new schema. So unable to test though – Kamal Chanda Apr 21 '22 at 22:56