Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-372

BSON.encode/decode should support primitive wrapper types as well

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.6.1
    • Component/s: None
    • Labels:
    • Fully Compatible

      Whereas JSON.parse can parse the "scalar" types as well, and as such can return not just BSONObject, but also String or Long, BSON.encode/decode only work with BSONObject.

      https://jira.mongodb.org/browse/JAVA-298

      I'd like to be able to also do for example

      byte[] aLong = BSON.encode(1l);
      byte[] aString = BSON.encode("string");

      For encode, this could be added as a new overload, for decode it would need to change the return type (from BSONObject to Object), so for the sake of compatibility, one would need to add a new method name.

            Assignee:
            antoine Antoine Girbal
            Reporter:
            thiloplanz Thilo Planz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: