Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Using a closure object marshaller which returns null results in out of sequence exceptions. #5

@chriserickson

Description

@chriserickson

I'd like to handle optionals via marshalling:

    JSON.registerObjectMarshaller(Optional) { Optional optional ->
         if (optional.present)
             return optional.get()
         else
             return null
    }

    assert (["Test": Optional.empty()] as JSON).toString(false) == '{"Test":null}' // throws out of sequence exception.

It appears to fail because the ClosureObjectMarshaller doesn't write a null value when the closure returns a null.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions