<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:51:55 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-280] BSONTimestamp and some other fields are not properly serialized to JSON and cannot be parsed back</title>
                <link>https://jira.mongodb.org/browse/JAVA-280</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;Calling toString() on a BSON object that has a BSONTimestamp field, yields a display of:&lt;/p&gt;

&lt;p&gt;&quot;start&quot; : 1298475384|324&lt;/p&gt;</description>
                <environment></environment>
        <key id="14856">JAVA-280</key>
            <summary>BSONTimestamp and some other fields are not properly serialized to JSON and cannot be parsed back</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</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="antoine">Antoine Girbal</assignee>
                                    <reporter username="rn@deftlabs.com">Ryan Nitz</reporter>
                        <labels>
                    </labels>
                <created>Wed, 23 Feb 2011 17:17:46 +0000</created>
                <updated>Wed, 19 Oct 2016 14:17:22 +0000</updated>
                            <resolved>Mon, 25 Apr 2011 18:00:53 +0000</resolved>
                                    <version>2.4</version>
                                    <fixVersion>2.5.3</fixVersion>
                                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="27060" author="auto" created="Tue, 29 Mar 2011 01:04:32 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;agirbal&apos;, u&apos;name&apos;: u&apos;agirbal&apos;, u&apos;email&apos;: u&apos;antoine@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-280&quot; title=&quot;BSONTimestamp and some other fields are not properly serialized to JSON and cannot be parsed back&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-280&quot;&gt;&lt;del&gt;JAVA-280&lt;/del&gt;&lt;/a&gt;: bug in BSONTimestamp JSON parse. Added BSON encoding of DBRef. Added test for JSON encode/decode all types.&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/a15a995d9a1485cbf059345d6863af53b1542f7f&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/a15a995d9a1485cbf059345d6863af53b1542f7f&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="26506" author="auto" created="Tue, 22 Mar 2011 18:32:10 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;agirbal&apos;, u&apos;name&apos;: u&apos;agirbal&apos;, u&apos;email&apos;: u&apos;antoine@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-280&quot; title=&quot;BSONTimestamp and some other fields are not properly serialized to JSON and cannot be parsed back&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-280&quot;&gt;&lt;del&gt;JAVA-280&lt;/del&gt;&lt;/a&gt;: NaN double value is not properly parsed back in JSON&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/17cf46df360896ad332ca63c9a2bd7698327f807&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/17cf46df360896ad332ca63c9a2bd7698327f807&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="26282" author="auto" created="Sat, 19 Mar 2011 00:20:04 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;agirbal&apos;, u&apos;name&apos;: u&apos;agirbal&apos;, u&apos;email&apos;: u&apos;antoine@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-280&quot; title=&quot;BSONTimestamp and some other fields are not properly serialized to JSON and cannot be parsed back&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-280&quot;&gt;&lt;del&gt;JAVA-280&lt;/del&gt;&lt;/a&gt;: BSONTimestamp and some other fields are not properly serialized to JSON and cannot be parsed back&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/5263bbeda933d50185745a99b66479e4539ffc99&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/5263bbeda933d50185745a99b66479e4539ffc99&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="26279" author="antoine" created="Fri, 18 Mar 2011 23:46:15 +0000"  >&lt;p&gt;After the fix, the following document is properly parsed from json, inserted in db, read from db, serialized into json:&lt;/p&gt;

&lt;p&gt;{&lt;br/&gt;
 &quot;str&quot; : &quot;asdfasd&quot; , &lt;br/&gt;
&quot;long&quot; : 5 , &lt;br/&gt;
&quot;dble&quot; : 0.4 , &lt;br/&gt;
&quot;bool&quot; : false , &lt;br/&gt;
&quot;date&quot; : &lt;/p&gt;
{ &quot;$date&quot; : &quot;2011-05-18T18:56:00Z&quot;}
&lt;p&gt; , &lt;br/&gt;
&quot;pat&quot; : &lt;/p&gt;
{ &quot;$regex&quot; : &quot;.*&quot; , &quot;$options&quot; : &quot;&quot;}
&lt;p&gt; , &lt;br/&gt;
&quot;oid&quot; : &lt;/p&gt;
{ &quot;$oid&quot; : &quot;4d83ab3ea39562db9c1ae2ae&quot;}
&lt;p&gt; , &lt;br/&gt;
&quot;ref&quot; : { &quot;$ref&quot; : &quot;test.test&quot; , &quot;$id&quot; : { &quot;$oid&quot; : &quot;4d83ab59a39562db9c1ae2af&quot;}} ,&lt;br/&gt;
&quot;code&quot; : &lt;/p&gt;
{ &quot;$code&quot; : &quot;asdfdsa&quot;}
&lt;p&gt; , &lt;br/&gt;
&quot;codews&quot; : { &quot;$code&quot; : &quot;ggggg&quot; , &quot;$scope&quot; : { }} ,&lt;br/&gt;
&quot;ts&quot; : &lt;/p&gt;
{ &quot;$ts&quot; : 1300474885 , &quot;$inc&quot; : 3}
&lt;p&gt; ,&lt;br/&gt;
&quot;null&quot; :  null &lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;Notes:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;json encoding/decoding was fixed for DBRef, Code, BSONTimestamp&lt;/li&gt;
&lt;/ul&gt;


&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;the timestamp representation still shows a number, cause it&apos;s faster to encode / decode. By comparison the date field has a lot of overhead in java (creates a date formatter for every date to be written). If you want a pretty print you can always call toString() on the timestamp object.&lt;/li&gt;
&lt;/ul&gt;


&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;the json parser was storing numbers with less than 10 digit in an int, otherwise in a long. I think this is arbitrary and can lead to bugs later on. When reading a stream of objects for a collection, they should have same type for a given field, so it should always be long.&lt;/li&gt;
&lt;/ul&gt;


&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;the Types.getByte() was totally not complete compared to BSONEncoder. Fixed to match.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Let me know if sounds ok and I&apos;ll commit.&lt;/p&gt;</comment>
                            <comment id="26174" author="antoine" created="Thu, 17 Mar 2011 22:37:23 +0000"  >&lt;p&gt;Here are most types we support:&lt;br/&gt;
&quot;str&quot; : &quot;&quot; , &lt;br/&gt;
&quot;int&quot; : 0 , &lt;br/&gt;
&quot;long&quot; : 0 , &lt;br/&gt;
&quot;float&quot; : 0.0 ,&lt;br/&gt;
&quot;dble&quot; : 0.0 ,&lt;br/&gt;
&quot;bool&quot; : true ,&lt;br/&gt;
&quot;date&quot; : &lt;/p&gt;
{ &quot;$date&quot; : &quot;2011-03-17T21:42:42Z&quot;}
&lt;p&gt; ,&lt;br/&gt;
&quot;pattern&quot; : &lt;/p&gt;
{ &quot;$regex&quot; : &quot;&quot; , &quot;$options&quot; : &quot;&quot;}
&lt;p&gt; ,&lt;br/&gt;
&quot;oid&quot; : &lt;/p&gt;
{ &quot;$oid&quot; : &quot;4d828076a395ceb40b028102&quot;}
&lt;p&gt; ,&lt;br/&gt;
&quot;bin&quot; : &amp;lt;Binary Data&amp;gt; , -&amp;gt; not parseable, that&apos;s ok&lt;br/&gt;
&quot;codeWScope&quot; : &lt;/p&gt;
{ &quot;$code&quot; : &quot;&quot; , &quot;$scope&quot; :  null }
&lt;p&gt; ,&lt;br/&gt;
&quot;code&quot; : &quot;&quot;, -&amp;gt; parseable but becomes string&lt;br/&gt;
&quot;ts&quot; : 1300398223|0 -&amp;gt; not parseable&lt;/p&gt;

&lt;p&gt;I guess I&apos;ll fix so that whatever is serialized can be parsed, besides Binary.&lt;/p&gt;</comment>
                            <comment id="26143" author="antoine" created="Thu, 17 Mar 2011 19:30:56 +0000"  >&lt;p&gt;Also, it&apos;s kind of bad that you cannot do mongoexport / mongoimport and get things identical&lt;/p&gt;

&lt;p&gt;foo:PRIMARY&amp;gt; db.accounts.insert(&lt;/p&gt;
{a: Timestamp()}
&lt;p&gt;)&lt;br/&gt;
foo:PRIMARY&amp;gt; db.accounts.find()&lt;br/&gt;
{ &quot;_id&quot; : ObjectId(&quot;4d825eeef7e844daacb16e96&quot;), &quot;a&quot; : &lt;/p&gt;
{ &quot;t&quot; : 1300389614000, &quot;i&quot; : 1 }
&lt;p&gt; }&lt;br/&gt;
here I&apos;m assuming the timestamp has type &quot;timestamp&quot; in the bson.&lt;/p&gt;

&lt;p&gt;$ ./mongoexport -d testdb -c accounts | ./mongoimport -d testdb -c accounts2&lt;/p&gt;

&lt;p&gt;foo:PRIMARY&amp;gt; db.accounts2.find()&lt;br/&gt;
{ &quot;_id&quot; : ObjectId(&quot;4d825eeef7e844daacb16e96&quot;), &quot;a&quot; : &lt;/p&gt;
{ &quot;t&quot; : NumberLong(&quot;1300389614000&quot;), &quot;i&quot; : 1 }
&lt;p&gt; }&lt;br/&gt;
here I&apos;m assuming the timestamp is just an object in the bson..&lt;/p&gt;

&lt;p&gt;For all native bson types, we should make sure they can be exported/imported in JSON reliably.&lt;/p&gt;</comment>
                            <comment id="26141" author="antoine" created="Thu, 17 Mar 2011 19:12:30 +0000"  >&lt;p&gt;As other example, regexp is like:&lt;/p&gt;
{ &quot;$regex&quot; : &quot;.*&quot; , &quot;$options&quot; : &quot;&quot;}</comment>
                            <comment id="26140" author="antoine" created="Thu, 17 Mar 2011 19:10:47 +0000"  >&lt;p&gt;so there are 2 ways the timestamp is represented today:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;with toString(): TS time:Thu Mar 17 11:52:18 PDT 2011 inc:0 -&amp;gt; nice enough&lt;/li&gt;
	&lt;li&gt;with JSON.serialize(): 1300387938|0 -&amp;gt; not good&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;when doing dbobject.toString(), it will call the JSON.serialize.&lt;br/&gt;
The serialized representation doesnt really need to be pretty, but right now the bigger issue is that the JSON cannot be parsed back.&lt;br/&gt;
So we should change that to smthing parseable.&lt;br/&gt;
A date is represented in a way that&apos;s easy to parse back:&lt;/p&gt;
{ &quot;$date&quot; : &quot;2011-03-17T19:00:09Z&quot;}

&lt;p&gt;If you look in shell,  a timestamp is represented by an object with no easy way to tell it&apos;s a timestamp:&lt;br/&gt;
foo:PRIMARY&amp;gt; a = &lt;/p&gt;
{field: Timestamp()}
&lt;p&gt;{ &quot;field&quot; : &lt;/p&gt;
{ &quot;t&quot; : 0, &quot;i&quot; : 0 }
&lt;p&gt; }&lt;/p&gt;

&lt;p&gt;So I think the format should be either:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;like shell: 
{ &quot;t&quot; : 0, &quot;i&quot; : 0 }
&lt;p&gt;, but then it&apos;s not clean to parse back, and not consistent with rest of driver&lt;/p&gt;&lt;/li&gt;
	&lt;li&gt;like java date: 
{ &quot;$ts&quot; : &quot;2011-03-17T19:00:09Z&quot;, &quot;$inc:&quot;: 123}&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="26081" author="rgnitz" created="Thu, 17 Mar 2011 13:46:34 +0000"  >
&lt;p&gt;Nod... they recommend using either commas or decimal points for fractions.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/ISO_8601#Times&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://en.wikipedia.org/wiki/ISO_8601#Times&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="26055" author="scotthernandez" created="Thu, 17 Mar 2011 03:05:46 +0000"  >&lt;p&gt;That won&apos;t display the increment part though, will it? Sometimes it is very useful to see that when looking at a bunch from the same second.&lt;/p&gt;

&lt;p&gt;What about Timestamp(&quot;&amp;lt;iso string&amp;gt;&quot;, ###)? We could make this universal with javascript and other drivers.&lt;/p&gt;</comment>
                            <comment id="26026" author="rgnitz" created="Wed, 16 Mar 2011 20:03:31 +0000"  >
&lt;p&gt;How about using the ISO 8601 format?&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/ISO_8601&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://en.wikipedia.org/wiki/ISO_8601&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="24734" author="eliot" created="Sat, 26 Feb 2011 05:05:01 +0000"  >&lt;p&gt;Any suggestions on the correct display?&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="15002">SERVER-2684</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <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|hrhcfz:</customfieldvalue>

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