FlatFilers / csvjson-app

Online conversion and formatting tools for JSON, CSV and SQL.

Home Page:https://www.csvjson.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mongdb json The word object is a problem

ali27001 opened this issue · comments

Invalid JSON.

Error: Parse error on line 3:
[ { "_id" : ObjectId("5e09ad9d52
----------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'
example json https://jsoneditoronline.org/?id=bcac623bb8cd401dbdb62f48bd1c3c68

@ali27001 this is not a valid JSON (see simple syntax diagram at https://www.json.org/json-en.html). What you have here may be a valida JavaScript object value but it is not JSON. The ObjectID(...) is the problem here as the error message makes clear.

yes right, but wouldn't it be good to support it?

Not really - JSON is plain, simple and safe. The moment you include executable code you invite a world of trouble and then it is no longer JSON. Recall that even though JSON stands for Java Script Object Notation, it is a standard of its own and in no way relies on JavaScript. The JavaScript spec includes a JSON compatible object literal notation. The sample you provided in JavaScript, not JSON.