Unable to read json from S3. "Invalid Json...ObjectId" error

TL:DR; good thing you got your problem fixed :slight_smile:

Hi again @P_Vivek , Let me extend (pun intended :wink: ) my last statement about the misunderstanding of JSON/eJSON with an example.

JSON format has only 5 value types: numbers, true/false, objects enclosed in {}, arrays enclosed in [] and everything else is string enclosed in quotes"". and then all keys are strings again. oh, and its root is also an object.

{ "key": { "just_a_sub_key": "value" } }

eJSON is a perfect JSON file with a trick: sub-keys in sub-objects can have a meaning.

{ "key": { "ejson_sub_key": "value" } }

$oid and $date are two of those meaningful sub keys. if you read with a JSON reader they are just some subkeys, but if you read with an eJSON parser, the “values” they refer to will be converted to ObjectId and Date objects further down your program.

a quick warning here is this: if you see any non-quoted variable name (other than true/false and numbers) then that file is not a valid JSON/eJSON file. you may say they are actually partial JavaScript files and are meant to be read without any parsing, mostly by the programs they are written for.

1 Like