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

How to add new field to bsoncxx::document::value?

    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Hello, I have a JSON string and I need to add a field to it. Here was my first approach:

      auto doc = from_json(jsonStr);
      document builder{ doc.release() };
      builder.append(kvp("$currentDate", make_document(kvp("lastModified", true))));
      

      But I realize that a builder cannot be initialized from a document::value in any way. So my question is how can I:

      • Parse a JSON string
      • Append a new field
      • Get the resulting document::value

            Assignee:
            ezra.chung@mongodb.com Ezra Chung
            Reporter:
            puya@motionmetrics.com Puya Daravi
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: