Skip to content
This repository has been archived by the owner on Aug 15, 2021. It is now read-only.

Deserialize undefined as None for Option #218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mraerino
Copy link

@mraerino mraerino commented Jul 6, 2021

CBOR knows these two types (spec):

  • 0xf6 => null
  • 0xf7 => undefined

Serde only knows Null afaik, or at least the Value enum doesn't have anything closer to represent undefined than Null.

In order for this to work well with Option we need to treat undefined the same as null when deserializing an Option.

this popped up when interacting between Rust and JS, when using { key: undefined } in JS and reading it into struct { key: Option<Foo> }

@mraerino mraerino marked this pull request as ready for review July 6, 2021 14:21
@mraerino mraerino changed the title Deserialize undefined as None for Option Deserialize undefined as None for Option Jul 6, 2021
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant