FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: add undefinedAsNil option to Encoder by eberlitz · Pull Request #278 · msgpack/msgpack-javascript · GitHub

feat: add undefinedAsNil option to Encoder - #278

Open
eberlitz wants to merge 2 commits into
msgpack:mainfrom
eberlitz:eb-undefinedAsNil
Open

eberlitz wants to merge 2 commits into
msgpack:mainfrom
eberlitz:eb-undefinedAsNil

Conversation

eberlitz commented Jun 12, 2025 •
edited
Loading

Copy link
Copy Markdown

Closes #150

Adds a new option to Encoder that is true by default ( to keep current behaviour). With this flag when ignoreUndefined is false, allows to distinguish null from undefined. It requires a custom extension to send undefined like :

extensionCodec.register({
    type: 0,
    encode: (value) => (value === undefined ? new Uint8Array([0]) : null),
    decode: () => undefined,
});

I also found another implementation (msgpackr) implements this as fixint 1 type 0 data 0, but I guess the consumer can decide in his custom extension

eberlitz marked this pull request as ready for review June 12, 2025 12:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

undefined becomes null after deserializing

1 participant


Back | FazBrowse Home | New Git URL