Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-565

JSONParser issue for ISODate

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 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)

            Assignee:
            bryan.reinero Bryan Reinero
            Reporter:
            schaffer M Schaffer
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: