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: 
{
    "_id": 
,
    "uid": "CA1236300671005",
    "deviceType": "GX440",
    "location": "",
    "deviceData": 
,
    "checkinData": []
}
example code:
    mongocxx::instance instance{};
    std::string uri_string = "mongodb://-------.feeneywireless.com:27017";
    mongocxx::client conn
;
    std::string dbname = "devices_db";
    auto db = conn[dbname];
    auto cursor = db["device"].find({});
    for(auto&& doc : cursor) {
        std::string teststring;
        try 
catch (exception e)
{ printf("error"); }        std:cout << teststring << std::endl;
    }
Looking at bsoncxx->json.cpp there is no check for an empty array.
    void visit_value(const types::b_array& value) 
I tried to add something along the lines of
    void visit_value(const types::b_array& value) {
        out << "[" << std::endl;
        if(value.value.length != 0) 
        out << "]";
    }
but couldn't figure out how to check for the empty array.
Thanks for your help.