[CXX-2291] How to add new field to bsoncxx::document::value? Created: 25/Jun/21  Updated: 07/Feb/24

Status: Backlog
Project: C++ Driver
Component/s: Docs Examples, Documentation
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Unknown
Reporter: Puya Daravi Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: post-5.0, size-xsmall
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: Reference Docs Improvements
Quarter: FY24Q3

 Description   

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


 Comments   
Comment by Kevin Albertson [ 28/Jun/21 ]

Hello puya@motionmetrics.com, thank you for the report! We will further investigate this after we have completed high priority work for upcoming server support. Thank you for your patience.

Generated at Wed Feb 07 22:05:27 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.