<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:52:35 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-565] JSONParser issue for ISODate</title>
                <link>https://jira.mongodb.org/browse/JAVA-565</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;I am using the JSON.parse method to parse a string query. It works fine until I have an ISODate in the query.&lt;br/&gt;
I&apos;ve included some sample code and the error below.&lt;br/&gt;
If I run the query directly on the cli it works fine.&lt;/p&gt;

&lt;p&gt; db.runCommand({aggregate:&quot;test&quot;, pipeline:&lt;span class=&quot;error&quot;&gt;&amp;#91;{$match:{date:ISODate(&amp;quot;2012-05-01T12:30&amp;quot;)}}&amp;#93;&lt;/span&gt;});&lt;/p&gt;

&lt;p&gt;Code: &lt;br/&gt;
 String queryString = &quot;{aggregate:\&quot;test\&quot;, pipeline:&lt;span class=&quot;error&quot;&gt;&amp;#91;{$match:{date:ISODate(\&amp;quot;2012-05-01T12:30\&amp;quot;)}}&amp;#93;&lt;/span&gt;}&quot;;&lt;br/&gt;
 BasicDBObject query = (BasicDBObject) JSON.parse(queryString);&lt;/p&gt;

&lt;p&gt;Error: &lt;br/&gt;
 com.mongodb.util.JSONParseException: &lt;br/&gt;
{aggregate:&quot;test&quot;, pipeline:&lt;span class=&quot;error&quot;&gt;&amp;#91;{$match:{date:ISODate(&amp;quot;2012-05-01T12:30&amp;quot;)}}&amp;#93;&lt;/span&gt;}                                                   ^&lt;br/&gt;
	at com.mongodb.util.JSONParser.parse(JSON.java:381)&lt;br/&gt;
	at com.mongodb.util.JSONParser.parseObject(JSON.java:414)&lt;br/&gt;
	at com.mongodb.util.JSONParser.parse(JSON.java:378)&lt;br/&gt;
	at com.mongodb.util.JSONParser.parseObject(JSON.java:414)&lt;br/&gt;
	at com.mongodb.util.JSONParser.parse(JSON.java:378)&lt;br/&gt;
	at com.mongodb.util.JSONParser.parseArray(JSON.java:718)&lt;br/&gt;
	at com.mongodb.util.JSONParser.parse(JSON.java:374)&lt;br/&gt;
	at com.mongodb.util.JSONParser.parseObject(JSON.java:414)&lt;br/&gt;
	at com.mongodb.util.JSONParser.parse(JSON.java:378)&lt;br/&gt;
	at com.mongodb.util.JSONParser.parse(JSON.java:328)&lt;br/&gt;
	at com.mongodb.util.JSON.parse(JSON.java:287)&lt;br/&gt;
	at com.mongodb.util.JSON.parse(JSON.java:272)&lt;/p&gt;
</description>
                <environment>Windows 7</environment>
        <key id="38105">JAVA-565</key>
            <summary>JSONParser issue for ISODate</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</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="bryan.reinero">Bryan Reinero</assignee>
                                    <reporter username="schaffer">M Schaffer</reporter>
                        <labels>
                    </labels>
                <created>Tue, 8 May 2012 18:01:02 +0000</created>
                <updated>Tue, 25 Jun 2013 16:51:11 +0000</updated>
                            <resolved>Mon, 27 Aug 2012 21:59:00 +0000</resolved>
                                    <version>2.7.3</version>
                                                    <component>API</component>
                                        <votes>1</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="159459" author="bernd.zuther" created="Fri, 31 Aug 2012 17:36:04 +0000"  >&lt;p&gt;I had the same problem and i could not understand the anwser of Bryan. Then i experience a little bit, with the JSON class.&lt;/p&gt;

&lt;p&gt;DBObject object = new BasicDBObject();&lt;br/&gt;
object.put(&quot;date&quot;, new Date());&lt;br/&gt;
String serialize = JSON.serialize(object);&lt;/p&gt;

&lt;p&gt;serialize is: { &quot;date&quot; : { &quot;$date&quot; : &quot;2012-08-31T17:30:01.882Z&quot;}}&lt;/p&gt;

&lt;p&gt;so this command should work.  &lt;br/&gt;
db.runCommand({aggregate:&quot;test&quot;, pipeline:[{$match:{ &quot;date&quot; : &lt;/p&gt;
{ &quot;$date&quot; : &quot;2012-08-31T17:30:01.882Z&quot;}
&lt;p&gt;}}]});&lt;/p&gt;

&lt;p&gt;PLEASE BE CAREFUL&lt;br/&gt;
:&lt;/p&gt;
{date:ISODate(&quot;2012-05-01T12:30&quot;)}
&lt;p&gt; must be replaced { &quot;date&quot; : &lt;/p&gt;
{ &quot;$date&quot; : &quot;2012-08-31T17:30:01.882Z&quot;}
&lt;p&gt;}}&lt;/p&gt;

&lt;p&gt;When using the mongodb hadoop adapter it is also imported to convert dates in this way:&lt;/p&gt;

&lt;p&gt;mongo.input.query={orderDate : {$gte : {$date : &quot;2012-08-30T00:00:00.000Z&quot;}, $lt:  {$date : &quot;2012-08-30T00:00:00.000Z&quot;}}}&lt;/p&gt;


</comment>
                            <comment id="131387" author="bryan.reinero@10gen.com" created="Tue, 12 Jun 2012 23:45:43 +0000"  >&lt;p&gt;The parser accepts these two date formats: seconds -&amp;gt; &quot;yyyy-MM-dd&apos;T&apos;HH:mm:ss&apos;Z&apos;&quot; or&lt;br/&gt;
seconds.milleseconds -&amp;gt; &quot;yyyy-MM-dd&apos;T&apos;HH:mm:ss.SSS&apos;Z&apos;&quot; &lt;/p&gt;

&lt;p&gt;Just add seconds to your $date value and the aggregation command should work. Here&apos;s the JSON doc that I had success with: &lt;/p&gt;

&lt;p&gt;{ &quot;aggregate&quot; : &quot;test&quot;, pipeline : [ {$match : { date : &lt;/p&gt;
{ $date : &quot;2012-05-01T12:30:00Z&quot; }
&lt;p&gt; } } ] }&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|hrgg7z:</customfieldvalue>

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