[CXX-224] BSONArray jsonString() always prints as object Created: 11/May/14 Updated: 08/Jul/14 Resolved: 08/Jul/14 |
|
| Status: | Closed |
| Project: | C++ Driver |
| Component/s: | BSON |
| Affects Version/s: | legacy-0.0-26compat-2.6.0, legacy-0.8.0 |
| Fix Version/s: | legacy-0.11.0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Itay Neeman | Assignee: | Tyler Brock |
| Resolution: | Done | Votes: | 0 |
| Labels: | legacy-cxx | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
The BSONArray type does not re-implement the jsonString() function, so it defaults to the BSONObj one. This means that arrays are always printed as:
rather than using square brackets, etc. We've implemented a custom function, which is here below:
It's basically identical with a couple of very small changes. I'm happy to submit a PR to get this fixed if it is agreeable. |
| Comments |
| Comment by Tyler Brock [ 26/Jun/14 ] | ||||||||||||
|
Resolving for now, let me know if you have any issues and we can reopen. | ||||||||||||
| Comment by Tyler Brock [ 25/Jun/14 ] | ||||||||||||
|
Ok, on the legacy branch we just merged upstream changes that will make this work correctly. Can you confirm that you can now print arrays using the mongo::tojson(<BSONArray>) method? | ||||||||||||
| Comment by Tyler Brock [ 19/Jun/14 ] | ||||||||||||
|
Moving back to "In Progress" as we are working on an upstream solution. | ||||||||||||
| Comment by Tyler Brock [ 18/Jun/14 ] | ||||||||||||
| Comment by Itay Neeman [ 18/Jun/14 ] | ||||||||||||
|
Yes, exactly. There is no way to format an outermost array as a proper array - it will always output as an object with string indices. | ||||||||||||
| Comment by Tyler Brock [ 18/Jun/14 ] | ||||||||||||
|
Hi Itay, It looks like this is only an issue when the top level is an array. Can you confirm that is the case? Code
Output
|