Search code examples
bond

Adding new fields to a Bond schema


Suppose I had serialized a given schema A, and then updated it to schema A' by adding a new nullable field X to it. Could I deserialize objects serialized using schema A with schema A'? After deserialization, will the new field have value null?


Solution

  • The answer depends on whether your field is marked "required" or not (see documentation)

    • If marked required, deserialization will fail.
    • If not required, you can deserialize objects with schema A' from a payload that was generated by schema A and the field X will be null.

    See also this SO question on schema evolution, and the section in the Bond documentation.