-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.7.3
-
Component/s: API
-
None
-
Environment:Windows 7
I am using the JSON.parse method to parse a string query. It works fine until I have an ISODate in the query.
I've included some sample code and the error below.
If I run the query directly on the cli it works fine.
db.runCommand({aggregate:"test", pipeline:[{$match:{date:ISODate("2012-05-01T12:30")}}]});
Code:
String queryString = "{aggregate:\"test\", pipeline:[{$match:{date:ISODate(\"2012-05-01T12:30\")}}]}";
BasicDBObject query = (BasicDBObject) JSON.parse(queryString);
Error:
com.mongodb.util.JSONParseException:
{aggregate:"test", pipeline:[{$match:{date:ISODate("2012-05-01T12:30")}}]} ^
at com.mongodb.util.JSONParser.parse(JSON.java:381)
at com.mongodb.util.JSONParser.parseObject(JSON.java:414)
at com.mongodb.util.JSONParser.parse(JSON.java:378)
at com.mongodb.util.JSONParser.parseObject(JSON.java:414)
at com.mongodb.util.JSONParser.parse(JSON.java:378)
at com.mongodb.util.JSONParser.parseArray(JSON.java:718)
at com.mongodb.util.JSONParser.parse(JSON.java:374)
at com.mongodb.util.JSONParser.parseObject(JSON.java:414)
at com.mongodb.util.JSONParser.parse(JSON.java:378)
at com.mongodb.util.JSONParser.parse(JSON.java:328)
at com.mongodb.util.JSON.parse(JSON.java:287)
at com.mongodb.util.JSON.parse(JSON.java:272)