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

Add JSON-like syntax to construct BSON object

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor - P4
    • Resolution: Fixed
    • None
    • 3.7.0, 3.7.0-beta1
    • BSON

    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

              clyde.bazile@mongodb.com Clyde Bazile III (Inactive)
              yoann.couillec@amadeus.com Yoann Couillec
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: