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

EJSON stringify in relaxed mode turns Int32s into strings

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: bson-4.0.3
    • Component/s: EJSON
    • None

      While looking into CLOUDP-62356, I encountered the following scenarios:

      EJSON.stringify({ intField: 222}) = "{ intField: 222 }"
      EJSON.stringify({ intField: Int32{ value: "222") = "{ "intField": "222" }"}}
      EJSON.stringify({ intField: Int32{ value: "222" } }, { relaxed: false }) = "{ "intField": { "$numberInt": "222" } }"

      In the second situation, it seems like the desired output would be:
      EJSON.stringify({ intField: Int32{ value: "222" } }) = "{ "intField": 222 }"
      with no quotes around 222 like in the first example. Otherwise, it gets recognized as a string when passed back into EJSON.parse.

            Assignee:
            matt.broadstone@mongodb.com Matt Broadstone
            Reporter:
            julia.ruddy@mongodb.com Julia Ruddy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: