Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-4222

Investigate NODE-4221 - EJSON stringify support ignoreUndefined

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • 0
    • Not Needed

      NODE-4221 Description

      How are you using Mongo? What version of the server and driver are you using?

      Have a client-side application where I want to serialize raw data using the extended-json in order to send data to the backend. That data contains objects with explicit undefined values. I also may have a case where the data contains explicit null values

      {zig: "zag", foo: undefined, bar: null}
      

      What is the feature/improvement you would like?

      I would like to be able to serialize the above with EJSON.stringify to 

      {zig: "zag", bar: null}

      Ideally the EJSON options includes an `ignoreUndefined` property like the regular serialize function.

      What use case would this feature/improvement enable?

      More explicit intention in encoding/serializing with the EJSON API

      Current workaround is to have some singleton represent values I would actually want as null, and have a replacer handle converting them to null and excluding undefines.

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            dbeng-pm-bot PM Bot
            Durran Jordan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: