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

add new Enum value for org.bson.json.JsonMode

    • Type: Icon: New Feature New Feature
    • Resolution: Won't Fix
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 3.0.0
    • Component/s: BSON
    • Labels:
      None
    • Environment:
      All

      For below code

          Document("a", 12).append("b", 14l).toJson()
      

      The output is

      { "a" : 12, "b" : { "$numberLong" : "14" } }
      

      If we change code as

          Document("a", 12).append("b", 14l).toJson(new JsonWriterSettings(JsonMode.SHELL))
      

      It generates

      { "a" : 12, "b" : NumberLong(14) }
      

      However in some circumstance, we expect to get the simple

      { "a" : 12, "b" : 14 }.
      

      In the implementation of JsonWriter.doWriteInt64(), there is a default switch case for such output, but it never goes there because JsonMode has only two exact enum value.

      So please add one new enum value for JsonMode, and then we can write code as

          Document("a", 12).append("b", 14l).toJson(new JsonWriterSettings(JsonMode.NEW_VALUE))
      

      and then can get the simple output

      { "a" : 12, "b" : 14 }
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            smxnju sun mingxin
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: