[CXX-587] to_json() throws exception on empty array Created: 28/Apr/15 Updated: 15/May/15 Resolved: 13/May/15 |
|
| Status: | Closed |
| Project: | C++ Driver |
| Component/s: | BSON |
| Affects Version/s: | 0.1.0 |
| Fix Version/s: | 0.2.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Robert Hougen | Assignee: | Mira Carey |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Epic Link: | PM-123 |
| Description |
|
we have a document that includes a collection with an array that is sometimes empty. If we access the database and iterate through the documents, the ones with empty arrays throw an exception when we use to_json(). example document: , , example code: ; std::string dbname = "devices_db"; auto cursor = db["device"].find({}); catch (exception e) { printf("error"); } std:cout << teststring << std::endl; Looking at bsoncxx->json.cpp there is no check for an empty array. I tried to add something along the lines of out << "]"; Thanks for your help. |
| Comments |
| Comment by Githook User [ 13/May/15 ] |
|
Author: {u'username': u'yhager', u'name': u'Yuval Hager', u'email': u'yhager@yhager.com'}Message: Closes #286 Signed-off-by: Adam Midvidy <amidvidy@gmail.com> |
| Comment by Githook User [ 13/May/15 ] |
|
Author: {u'username': u'yhager', u'name': u'Yuval Hager', u'email': u'yhager@yhager.com'}Message: Signed-off-by: Adam Midvidy <amidvidy@gmail.com> |
| Comment by Andrew Morrow (Inactive) [ 12/May/15 ] |
| Comment by Yuval Hager [ 11/May/15 ] |
|
Not the OP, but here's a similar PR to fix this: https://github.com/mongodb/mongo-cxx-driver/pull/286 |
| Comment by Andrew Morrow (Inactive) [ 01/May/15 ] |
|
Thanks for sending that. If you send that as a GitHub pull request we can merge it for you, or just let us know if you don't want to do that and we can fix on our side. |
| Comment by Robert Hougen [ 30/Apr/15 ] |
|
I think I found a fix which works for both empty arrays and empty documents. void visit_children(const bsoncxx::document::view& view) { //end of added code first = false; } |
| Comment by Andrew Morrow (Inactive) [ 28/Apr/15 ] |
|
Thanks for the bug report, we will take a look. We appreciate your testing out the alpha of the new driver! |