0

I am trying to use emacs-lisp to interact with a MongoDB. Here is an example of a string that mongo returns, that emacs cannot read. The problem is the unquoted ObjectId and ISODate items (if I put quotes around them, then it parses fine).

(json-read-from-string "[ { \"_id\" : ObjectId(\"589f59860a25be50ecd9a6d0\"), \"date-added\" : ISODate(\"2017-02-11T18:35:50.046Z\") }, { \"_id\" : ObjectId(\"589f598c0a25be50ecd9a6d1\"), \"date-added\" : ISODate(\"2017-02-11T18:35:56.634Z\") } ]")

Is there a way to get the json library to read this kind of json? Right now what I do is "quote" and "dequote" the json string, but it means I have to keep it up to date with all the things that mongo might return one day.

  • Maybe you could add add entries for upper case letters into json-readtable. – npostavs Feb 11 '17 at 19:14
  • That is an interesting idea. I will look into that. Thanks. – John Kitchin Feb 11 '17 at 19:45
  • Well... this isn't JSON really. It's JavaScript. Why not try using Node.js for this? – wvxvw Feb 11 '17 at 20:04
  • How would you do that through emacs? I have a comint-mode that sends queries to mongo as json, and it sends back what it calls json, except it has those things in it. – John Kitchin Feb 11 '17 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.