[JAVA-1175] Expose com.mongodb.util.ClassMapBasedObjectSerializer to Allow Overriding of ObjectSerializers for Specific Types Created: 21/Apr/14 Updated: 08/Nov/17 Resolved: 08/Nov/17 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | JSON |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Stephen Lee | Assignee: | Unassigned |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
I noticed that JSONSerializers.getStrict() and JSONSerializers.getLegacy() are implemented using the package-accessible com.mongodb.util.ClassMapBasedObjectSerializer class. In the case of org.bson.types.Binary, the legacy serializer doesn't produce valid JSON; it produces a bare, unquoted string <Binary Data>. The strict serializer produces valid JSON (quoted) string but obviously can be very, very verbose. I'd like to be able to override the serializer and produce something in between the legacy and strict implementations for Binary: a valid JSON string that's a truncated string representation that the strict implementation outputs. This would require making the com.mongodb.util.ClassMapBasedObjectSerializer public. |
| Comments |
| Comment by Jeffrey Yemin [ 08/Nov/17 ] |
|
The org.bson.json.JsonWriter class now has comprehensive support for customizing the JSON output of any BSON type. See |
| Comment by Jeffrey Yemin [ 22/Apr/14 ] |
|
Can you describe your use case for this request? |