[JAVA-2000] Add toString() methods to Bson instances returned from static builder methods Created: 06/Oct/15 Updated: 31/Jan/18 Resolved: 15/Jun/16 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | BSON |
| Affects Version/s: | 3.1.0 |
| Fix Version/s: | 3.3.0 |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Jeff Schnitzer | Assignee: | Jeffrey Yemin |
| Resolution: | Done | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Description |
|
The objects returned by the Filters.* and Aggregates.* and other static builder methods are really hard to debug since they log opaquely. Please add toString() methods Builder classes to include:
|
| Comments |
| Comment by Githook User [ 15/Jun/16 ] | |
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: Includes Filters, Projections, Updates, Sorts, Aggregates, and Accumulators | |
| Comment by Jeffrey Yemin [ 06/Oct/15 ] | |
|
Sure, that's true. I'll leave this open then, and you can use my suggestion as a workaround until it's fixed. | |
| Comment by Jeff Schnitzer [ 06/Oct/15 ] | |
|
To turn a Bson into JSON, yes - but it doesn't need to be JSON. Simply having all relevant implementations stringify their member data in an arbitrary form is incredibly useful while logging and debugging. toString()'s contract does not require any particular format. | |
| Comment by Jeffrey Yemin [ 06/Oct/15 ] | |
|
In order to properly turn a Bson instance into a JSON string, a CodecRegistry is needed. That's why there is currently no toString() method available. You can call toString on:
and it will be guaranteed to work. |