Skip to content

Is it possible to deserialise a union schema disregarding the order of records? #248

Closed Answered by dstelljes
devantler asked this question in Q&A
Discussion options

You must be logged in to vote

The behavior of the schema reader is actually defined by the spec:

A schema or protocol may not contain multiple definitions of a fullname. Further, a name must be defined before it is used (“before” in the depth-first, left-to-right traversal of the JSON parse tree, where the types attribute of a protocol is always deemed to come “before” the messages attribute.)

So, even though it looks counter-intuitive, the spec-compliant way to express that union would be:

[
    {
        "name": "RecordB",
        "type": "record",
        "fields": [
            {
                "name": "RecordA",
                "type": {
                    "name": "RecordA",
                    "type": "record"

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@devantler
Comment options

Answer selected by devantler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants