<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:57:52 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-2702] BasicDBObject.parse fails to parse json if it contains big numbers</title>
                <link>https://jira.mongodb.org/browse/JAVA-2702</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;&lt;b&gt;Input:&lt;/b&gt;&lt;br/&gt;
JSON with big number (exceeds java.lang.Long limits).&lt;br/&gt;
Sample code:&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;BasicDBObject obj = BasicDBObject.parse(&quot;{\&quot;bigNum\&quot;: 11111111111111111111111}&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;   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;System.out.println(obj);&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;&lt;b&gt;Expected behavior:&lt;/b&gt;&lt;br/&gt;
BasicDBObject.parse handles such number as Decimal128 (added in 3.4)&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Actual behavior:&lt;/b&gt;&lt;br/&gt;
BasicDBObject.parse fails with NumberFormatException. (JsonScanner.scanNumber tries to parse number as Integer, Long or Double, but not Decimal128).&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;Exception in thread &quot;main&quot; java.lang.NumberFormatException: For input string: &quot;11111111111111111111111&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;&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;	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)&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;	at java.lang.Long.parseLong(Long.java:592)&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;	at java.lang.Long.parseLong(Long.java:631)&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;	at org.bson.json.JsonScanner.scanNumber(JsonScanner.java:437)&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;	at org.bson.json.JsonScanner.nextToken(JsonScanner.java:93)&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;	at org.bson.json.JsonReader.popToken(JsonReader.java:492)&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;	at org.bson.json.JsonReader.readBsonType(JsonReader.java:136)&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;	at com.mongodb.DBObjectCodec.readDocument(DBObjectCodec.java:345)&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;	at com.mongodb.DBObjectCodec.decode(DBObjectCodec.java:138)&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;	at com.mongodb.DBObjectCodec.decode(DBObjectCodec.java:61)&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;	at com.mongodb.BasicDBObject.parse(BasicDBObject.java:74)&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;	at com.mongodb.BasicDBObject.parse(BasicDBObject.java:61)&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;</description>
                <environment></environment>
        <key id="471671">JAVA-2702</key>
            <summary>BasicDBObject.parse fails to parse json if it contains big numbers</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="13202">Works as Designed</resolution>
                                        <assignee username="ross@mongodb.com">Ross Lawley</assignee>
                                    <reporter username="danilov.m.u@gmail.com">Mikhail Danilov</reporter>
                        <labels>
                    </labels>
                <created>Wed, 13 Dec 2017 15:33:55 +0000</created>
                <updated>Fri, 27 Oct 2023 13:21:10 +0000</updated>
                            <resolved>Thu, 14 Dec 2017 18:27:59 +0000</resolved>
                                    <version>3.4.3</version>
                    <version>3.6.0</version>
                                                    <component>JSON</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="1752226" author="jeff.yemin" created="Thu, 14 Dec 2017 18:27:59 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=mdanilov&quot; class=&quot;user-hover&quot; rel=&quot;mdanilov&quot;&gt;mdanilov&lt;/a&gt; thanks for the feedback and for working through this issue.  For now, your best bet is to pre-process your JSON, as you would have to do with other MongoDB BSON types that have no native JSON representation (e.g. ObjectId, Date)&lt;/p&gt;</comment>
                            <comment id="1752221" author="danilov.m.u@gmail.com" created="Thu, 14 Dec 2017 18:24:41 +0000"  >&lt;p&gt;Jeff, thanks for explanation.&lt;br/&gt;
I suggest to use Decimal128 only where Double or Long are not applicable (currently using size as the only defining factor) as an alternative to throwing NumberFormatException. &lt;br/&gt;
It will provide more use cases for JsonReader-based parsers and hopefully will not be confusing for clients. (In my case js-style json strings are provided by 3rd party and it seems like I&apos;m forced to do some processing to make it valid extended json before feeding to mongo parsers to overcome NumberFormatException).&lt;/p&gt;
</comment>
                            <comment id="1751797" author="jeff.yemin" created="Thu, 14 Dec 2017 13:49:57 +0000"  >&lt;p&gt;&lt;tt&gt;JsonReader&lt;/tt&gt; already supports &lt;tt&gt;Decimal128&lt;/tt&gt;  but requires a specific escape syntax to specify values of that type, as specified in our &lt;a href=&quot;https://github.com/mongodb/specifications/blob/master/source/extended-json.rst#extended-json-format&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Extended JSON specification&lt;/a&gt;.  The JSON input has to look 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;d&quot; : {&quot;$numberDecimal&quot; : &quot;1.400&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;The rationale for distinguishing Decimal128 values from Double values is that they don&apos;t just differ in size, but in semantics.  Decimal128 values can represent decimal values like &lt;tt&gt;0.1&lt;/tt&gt; exactly, for example, while Double values can not.  They can also represent trailing zeros losslessly, so, for example, &lt;tt&gt;1.40&lt;/tt&gt; is distinct from &lt;tt&gt;1.400&lt;/tt&gt;.  See the &lt;a href=&quot;https://en.wikipedia.org/wiki/Decimal128_floating-point_format&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Wikipedia article&lt;/a&gt; for more details.&lt;/p&gt;</comment>
                            <comment id="1751627" author="danilov.m.u@gmail.com" created="Thu, 14 Dec 2017 04:52:22 +0000"  >&lt;p&gt;BasicDBObject#parse uses JsonReader under the hood. And JsonReader&apos;s javadoc says:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Reads a JSON in one of the following modes:&lt;br/&gt;
Strict mode that conforms to the JSON RFC specifications.&lt;br/&gt;
JavaScript mode that that most JavaScript interpreters can process&lt;br/&gt;
Shell mode that the mongo shell can process. This is also called &quot;extended&quot; JavaScript format.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Also in driver documentation &lt;a href=&quot;http://mongodb.github.io/mongo-java-driver/3.6/bson/extended-json/:&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://mongodb.github.io/mongo-java-driver/3.6/bson/extended-json/:&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;JsonReader automatically detects the JSON flavor in the string, so you do not need to specify it.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Based on that I guess that feature request for Decimal128 support in JsonReader/JsonScanner should be created. And this issue should be discarded since BasicDBObject#parse correctly handles json according to javadoc. &lt;/p&gt;

&lt;p&gt;Any thoughts on that?&lt;/p&gt;</comment>
                            <comment id="1750967" author="danilov.m.u@gmail.com" created="Wed, 13 Dec 2017 16:12:44 +0000"  >&lt;p&gt;Hello @ross.lawley,&lt;/p&gt;

&lt;p&gt;Thanks for quick response. &lt;/p&gt;

&lt;p&gt;I used BasicDBObject as a replacement for com.mongodb.util.JSON (is deprecated in 3.6) and extended-json was not mentioned in JSON&apos;s javadoc.&lt;/p&gt;

&lt;p&gt;Does driver offers any other tools to parse arbitrarary json string (non-extended) to BasicDBObject? &lt;/p&gt;</comment>
                            <comment id="1750930" author="ross@10gen.com" created="Wed, 13 Dec 2017 15:48:24 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=mdanilov&quot; class=&quot;user-hover&quot; rel=&quot;mdanilov&quot;&gt;mdanilov&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;Thanks for the ticket, this is currently expected behaviour as &lt;tt&gt;BasicDBObject#parse&lt;/tt&gt; handles &lt;a href=&quot;https://docs.mongodb.com/manual/reference/mongodb-extended-json&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;extended-json&lt;/a&gt;, as stated in the API documentation:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;Parses a string in MongoDB Extended JSON format to a &lt;tt&gt;BasicDBObject&lt;/tt&gt;&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;Ross&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|htdqin:</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>