[CSHARP-831] Provide BsonDocument.Pretty() method for debugging purposes. Created: 02/Sep/13 Updated: 11/Mar/19 Resolved: 22/Oct/13 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | William Steinberg | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | bson | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
When displaying a BsonDocument, with default ToString(), it produces a nice compact linear version. |
| Comments |
| Comment by Robert Stam [ 22/Oct/13 ] | |||||||
|
We are not planning to add a method called Pretty because there is already a documented way to do this. If you want to use the name Pretty in your code you can define an extension method of your own called Pretty. For example:
| |||||||
| Comment by William Steinberg [ 26/Sep/13 ] | |||||||
|
Yes. I see that there is a workaround. Could we add pretty() anyway? | |||||||
| Comment by Robert Stam [ 26/Sep/13 ] | |||||||
|
Instead of using ToString use ToJson which allows you to use JsonWriterSettings to control the format of the output. For example:
outputs:
Which I think is what you are asking for (i.e. multiline output). |