Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NODE-2253: Support for v1 Extended JSON #339

Merged
merged 8 commits into from
Jan 7, 2020
Merged

Conversation

durran
Copy link
Member

@durran durran commented Dec 3, 2019

  • Adds a legacy: true option to serialize, deserialize, parse, and stringify.
  • Adds tests for cases where v1 and v2 extjson differ.

- Adds a legacy: true option to serialize and stringify
- Adds tests for cases where v1 and v2 extjson differ.
@durran durran changed the title NODE-2253: Support for v1 Extended JSON [WIP] NODE-2253: Support for v1 Extended JSON Dec 16, 2019
@durran durran requested a review from mbroadst December 16, 2019 10:16
Copy link
Contributor

@imlucas imlucas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with update to docs in README

Copy link
Contributor

@imlucas imlucas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

const base64String = Buffer.isBuffer(this.buffer)
? this.buffer.toString('base64')
: Buffer.from(this.buffer).toString('base64');

const subType = Number(this.sub_type).toString(16);
if (options.legacy) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to ensure options exists, otherwise you'll have an error on trying to access legacy on it. Recommend:

  • typeof options !== 'undefined' && options.legacy
  • adding a options = options || {} above
  • make some helper function to check this, since its likely you are doing it many places

I realize this may be an existing issue prior to the changes introduced here, but this PR would necessarily introduce such a bug into every method now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbroadst I can take care of this tmrw if @durran doesn't beat me to it and you give me push access to this repo.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@imlucas added you as a collaborator

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Pushed

@mbroadst mbroadst merged commit 35ae72f into master Jan 7, 2020
@mbroadst mbroadst deleted the legacy-extended-json branch January 7, 2020 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants