<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:51:32 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>[JAVA-111] JSON.parse() and serialize() do not preserve the _id field across serializations as expected</title>
                <link>https://jira.mongodb.org/browse/JAVA-111</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;The current behavior might be intended, but it seems that the JSON utility class does not properly handle ObjectIds when serializing and parsing. I would expect that creating a DBObject (and saving to generate an ObjectId), serializing it, and then parsing would result in a new DBObject instance with the same _id as the original. That is, I would expect that parse(serialize(o)).id to equal o.id.  This is not the case. &lt;/p&gt;

&lt;p&gt;The following code illustrates the problem:&lt;/p&gt;

&lt;p&gt;DBCollection c = getMeACollection();&lt;/p&gt;

&lt;p&gt;// clear the collection&lt;br/&gt;
c.remove(new BasicDBObject()); &lt;/p&gt;

&lt;p&gt;DBObject o = new BasicDBObject();&lt;br/&gt;
c.save(o);&lt;br/&gt;
String json = JSON.serialize(o);&lt;br/&gt;
o = (DBObject)JSON.parse(json);&lt;br/&gt;
c.save(o);&lt;/p&gt;

&lt;p&gt;results in two documents in the collection (I would expect one):&lt;/p&gt;

{ &quot;_id&quot; : ObjectId(&quot;4bd62964037394994a295cd3&quot;) }
{ &quot;_id&quot; : &quot;4bd62964037394994a295cd3&quot; }

&lt;ul&gt;
	&lt;li&gt;
	&lt;ul&gt;
		&lt;li&gt;Interestingly, the ObjectId class makes an attempt at dealing with this (see ObjectId.equals and ObjectId.massageToObjectId), but it does not seem to be handled thoroughly enough to prevent the type of behavior I illustrate in my example.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;
</description>
                <environment></environment>
        <key id="11845">JAVA-111</key>
            <summary>JSON.parse() and serialize() do not preserve the _id field across serializations as expected</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</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="9">Done</resolution>
                                        <assignee username="eliot">Eliot Horowitz</assignee>
                                    <reporter username="william.shulman@gmail.com">William Shulman</reporter>
                        <labels>
                    </labels>
                <created>Mon, 26 Apr 2010 20:26:16 +0000</created>
                <updated>Fri, 29 Oct 2010 02:49:58 +0000</updated>
                            <resolved>Tue, 25 May 2010 21:26:03 +0000</resolved>
                                                    <fixVersion>2.0</fixVersion>
                                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="14434" author="william.shulman@gmail.com" created="Tue, 25 May 2010 15:39:18 +0000"  >&lt;p&gt;This can be closed now. Made changes to the Java driver to fix this&lt;/p&gt;</comment>
                            <comment id="13896" author="william.shulman@gmail.com" created="Tue, 27 Apr 2010 03:35:29 +0000"  >&lt;p&gt;Looks related to &lt;a href=&quot;https://jira.mongodb.org/browse/PYTHON-69&quot; title=&quot;Provide JSON encoder / decoder for Mongo &amp;quot;strict JSON&amp;quot;&quot; class=&quot;issue-link&quot; data-issue-key=&quot;PYTHON-69&quot;&gt;&lt;del&gt;PYTHON-69&lt;/del&gt;&lt;/a&gt; (&lt;a href=&quot;http://jira.mongodb.org/browse/PYTHON-69&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;http://jira.mongodb.org/browse/PYTHON-69&lt;/a&gt;) and &lt;a href=&quot;http://www.mongodb.org/display/DOCS/Mongo+Extended+JSON&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://www.mongodb.org/display/DOCS/Mongo+Extended+JSON&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;More generally it is probably an issue for most drivers.&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|hrhd67:</customfieldvalue>

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