Skip to content

Handling Nullable parameter #12

@bluemax75

Description

@bluemax75

Is there a way of handling a parameter that may be null?
To support a JSON that may come as:

{ "key": 2 }

or as

{ "key": null }

I already tried using Option this way:

type 
  Test = object
    key: Option[int]

This works for the first JSON but the second one gives the following error

Error: unhandled exception: Number expected. At offset: 6 [JsonError]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions