Hilmi
Hilmi

Reputation: 3441

Java: JSONParseException

All I'm trying to do is to parse very simple json line, even its valid i dont know why its throwing an error

the line is

com.mongodb.util.JSONParseException: 
{publish_status:'active',activation_date:{$lt:new Date()},expiration_date:{$gt:new Date()}}
                                               ^

what is wrong with the new Date() as a value?

Upvotes: 0

Views: 887

Answers (2)

ankit-jain
ankit-jain

Reputation: 26

I tried using the new date() in mongo DB 2.2.3 directly and it worked .. it created a value of ISODate.

You may try using this:

{publish_status:'active',activation_date:new Date(),expiration_date:new Date()}

Upvotes: 1

Ryan Stewart
Ryan Stewart

Reputation: 128809

That's not valid JSON at all. JSON syntax is defined on json.org, and it's always a string key with a value that's one of a string, number, boolean, null, array, or object. You're writing a Mongo query from Java. You should reformulate your question and retag appropriately.

Upvotes: 3

Related Questions