Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-1455

Add JSON-like syntax to construct BSON object

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor - P4
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Not planned
    • Component/s: BSON
    • Labels:

      Description

      Today in mongo-cxx-driver, there are several ways of constructing a BSON object
      http://mongodb.github.io/mongo-cxx-driver/mongocxx-v3/working-with-bson/

      None of them provides a JSON-like way despite the fact it exists generally to construct JSON documents
      https://github.com/nlohmann/json

      I propose to use a similar construction to build BSON documents. Then, we will be able to write:

      document friends {{"friend",{{"_id", json::id{}},
                                                   {"name","jean"},
                                                   {"dob",1970}}}};
      

      instead of

      bsoncxx::document::value = document{} << "friends" << open_document 
                                                                                          << "_id" << bsoncxx::oid() 
                                                                                          << "name" << "jean"
                                                                                          << " dob" << 1970
                                                                                          << close_document
                                                                                          << finalize;
      

      I started the development of it

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated: