<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 22:04:34 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[CXX-1995] Standard string from bson to son to look up the specific value </title>
                <link>https://jira.mongodb.org/browse/CXX-1995</link>
                <project id="11980" key="CXX">C++ Driver</project>
                    <description>&lt;p&gt;Hello dear MongoDB guys,&lt;/p&gt;

&lt;p&gt;I can visit a mongodb data-base in remote server, get the data-base and correponding collection.&lt;/p&gt;

&lt;p&gt;I filter kip with the specific ids, the information can be displayed as the standard string, however, it cannot be queried with the interested keys to get the data-list.&lt;/p&gt;

&lt;p&gt;My code is:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;int main() {&lt;br/&gt;
    // The mongocxx::instance constructor and destructor initialize and shut down the driver,&lt;br/&gt;
    // respectively. Therefore, a mongocxx::instance must be created before using the driver and&lt;br/&gt;
    // must remain alive for as long as the driver is in use.&lt;br/&gt;
    using bsoncxx::builder::basic::kvp;&lt;br/&gt;
    using bsoncxx::builder::basic::make_document;&lt;br/&gt;
    mongocxx::instance inst{};&lt;/p&gt;

&lt;p&gt;    mongocxx::client conn{mongocxx::uri{&quot;mongodb://192.168.7.202/#video-label&quot;}};&lt;br/&gt;
    /* list databases */&lt;br/&gt;
    for(auto doc : conn.list_databases()) &lt;/p&gt;
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;Unknown macro: {
        std}&lt;/span&gt; &lt;/div&gt;
&lt;p&gt;    /* access or create a database */&lt;br/&gt;
    mongocxx::database db = conn&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;workstation&amp;quot;&amp;#93;&lt;/span&gt;;&lt;br/&gt;
    mongocxx::collection collection = db&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;videolabels&amp;quot;&amp;#93;&lt;/span&gt;;&lt;br/&gt;
    /* query one doc that match with filter */&lt;br/&gt;
    mongocxx::cursor cursor = collection.find(make_document(kvp(&quot;id&quot;, &quot;m-2417&quot;)));&lt;br/&gt;
    std::string raw_json = &quot;&quot;;&lt;br/&gt;
    for (auto doc : cursor) &lt;/p&gt;
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;Unknown macro: {
        raw_json = bsoncxx}&lt;/span&gt; &lt;/div&gt;
&lt;p&gt;    const auto raw_json_length = static_cast&amp;lt;int&amp;gt;(raw_json.length());&lt;br/&gt;
    JSONCPP_STRING err;&lt;br/&gt;
    Json::Value root;&lt;br/&gt;
    Json::CharReaderBuilder builder;&lt;br/&gt;
    Json::Reader old_reader;&lt;/p&gt;

&lt;p&gt;    if(old_reader.parse(raw_json,root)) &lt;/p&gt;
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;Unknown macro: {
        std}&lt;/span&gt; &lt;/div&gt;

&lt;p&gt;    const std::unique_ptr&amp;lt;Json::CharReader&amp;gt; reader(builder.newCharReader());&lt;br/&gt;
    if (!reader-&amp;gt;parse(raw_json.c_str(), raw_json.c_str() + raw_json_length, &amp;amp;root,&lt;br/&gt;
                       &amp;amp;err)) &lt;/p&gt;
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;Unknown macro: {
      std}&lt;/span&gt; &lt;/div&gt;
&lt;p&gt;    std::cout&amp;lt;&amp;lt;root.asString() &amp;lt;&amp;lt; std::endl;&lt;br/&gt;
    const std::string keyboard_str = root&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;keyboard&amp;quot;&amp;#93;&lt;/span&gt;.asString();&lt;br/&gt;
    std::cout&amp;lt;&amp;lt;keyboard_str &amp;lt;&amp;lt;std::endl;&lt;br/&gt;
}&lt;/p&gt;&lt;/blockquote&gt;


&lt;p&gt;As I know, the jsoncpp and other corresponding C++ library can only parse the string with the backslash between double-quote. With standard string as input, I cannot get the &quot;root&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;keyboard&amp;quot;&amp;#93;&lt;/span&gt;.asString()&quot;. Is there any solution to resolve this? The returned value of bsoncxx and mongocxx API can be queried by jsoncpp.&lt;br/&gt;
Thanks &amp;amp; Regards!&lt;br/&gt;
Momo &lt;/p&gt;</description>
                <environment></environment>
        <key id="1315831">CXX-1995</key>
            <summary>Standard string from bson to son to look up the specific value </summary>
                <type id="2" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14711&amp;avatarType=issuetype">New Feature</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="13203">Gone away</resolution>
                                        <assignee username="samantha.ritter@mongodb.com">Samantha Ritter</assignee>
                                    <reporter username="1921shanghai@gmail.com">&#33707; &#33707;</reporter>
                        <labels>
                    </labels>
                <created>Wed, 15 Apr 2020 12:03:11 +0000</created>
                <updated>Fri, 27 Oct 2023 19:48:19 +0000</updated>
                            <resolved>Mon, 24 Aug 2020 19:48:48 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="3297496" author="samantha.ritter@10gen.com" created="Wed, 22 Jul 2020 19:54:04 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=1921shanghai%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;1921shanghai@gmail.com&quot;&gt;1921shanghai@gmail.com&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;Thank you for opening this ticket!&lt;/p&gt;

&lt;p&gt;Are you able to provide the structure of the documents you are using?  I&apos;m guessing that they have a field called &quot;keyboard&quot; with a string value, like this:&lt;/p&gt;
&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;{ &quot;keyboard&quot; : &quot;Yamaha&quot; }&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;I think that you are asking about how to access the value of the &quot;keyboard&quot; field.  Here&apos;s how to do that:&lt;/p&gt;
&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;// Construct the document&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;auto doc = make_document(kvp(&quot;keyboard&quot;, &quot;Yamaha&quot;));&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&amp;nbsp;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;// &quot;doc&quot; is a document::value, but the document::view class has all the convenience functions&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;auto doc_view = doc.view();&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&amp;nbsp;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;// Access the &quot;keyboard&quot; field&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;auto keyboard_value = doc_view[&quot;keyboard&quot;].get_utf8().value;&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;Does that help?&lt;/p&gt;

&lt;p&gt;Thanks,&lt;br/&gt;
Samantha Ritter&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hx2xb3:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>