[JAVA-2489] Add to Enum<JsonMode> Created: 13/Apr/17 Updated: 22/Jun/17 Resolved: 22/Jun/17 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | BSON, JSON |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Edem Nsefik | Assignee: | Unassigned |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Description |
|
Currently ENum<JsonMode> has the Values 'STRICT' or 'SHELL' as a parameter value to be passed for example to JsonWriterSettings(JsonMode.SHELL) We need a 3rd option call it SIMPLE or NOTEXTENDED in which the bson extended json values are returned as raw values without using the bson extended json datatypes as in JsonMode.SHELL or returning a json document for the bson extended json datatypes as in JsonMode.STRICT For example a document with a field of type Long will render the following json JsonMode.STRICT - { "field1" : { "$numberLong" : "10000000000000" }JsonMode.SIMPLE - { "field1" : 10000000000000 }Currently, I am having to do regex substitution on a json returned using JsonMode.SHELL. |
| Comments |
| Comment by Jeffrey Yemin [ 22/Jun/17 ] | |||||||||||||||||||||
|
I linked to the related tickets, which I believe will satisfy this use case. | |||||||||||||||||||||
| Comment by Jeffrey Yemin [ 25/Apr/17 ] | |||||||||||||||||||||
|
Hi Edem, In scope of another issue addressed in the upcoming 3.5 release of the driver, applications will be able to output whatever JSON is required for each type, using custom converters. The code will look something like this:
and the output would look like this:
I think that will provide more flexibility for applications with specific output requirements than we could achieve with an additional OutputMode, which might work for some applications but be inappropriate for others. | |||||||||||||||||||||
| Comment by Edem Nsefik [ 25/Apr/17 ] | |||||||||||||||||||||
|
Great to hear that this is being worked on across the driver range. This feature request is really about outputting simple JSON without the need to necessarily go back to the BSON equivalent. As for fidelity, I'd leave that to the user types that will interplay with the simple JSON. If the BSON is Long it presumably will be read into a user type Long(64bits) regardless of its size, otherwise we'd get errors trying to read a big Long into an Int(32bits) | |||||||||||||||||||||
| Comment by Craig Wilson [ 13/Apr/17 ] | |||||||||||||||||||||
|
We are currently working on exactly this type of thing across all our drivers. A few questions for you: Craig |