How do you enter JSON manually?

Hello!

I need to enter some JSON data. Just opening a JSON file in Emacs seems a bit error prone to me. Other approaches I might consider is just using Excel (or another spreadsheet tool) and writing some converter. But it feels like someone should have done this better somehow, somewhere.

When you are in need to enter some JSON manually or semi-manually, how do you prefer to do it?

Thanks!
Teodor

Clojure maps and then transform with Metosin muuntaja to json.

1 Like

Thanks for your reply, @huima. And welcome to the community!

I guess that saves you from writing some commas. Do you prefer to do that even if you plan to include the JSON file in source code?

I’d just use EDN in Clojure projects, but I’m choosing JSON when I want something I can use without dependencies from Python.

Since I developer TypeScript most of the day, I would launch a Console and write some JavaScript. Then JSON.stringify(x) to get JSON. Or I would also start a demo.coffee file, and call JSON.stringify(x) in CoffeeScript running in Node.js .

Oh! Is that what Muuntaja is for? Cool!

Since the dawn of time (re: my start with Clojure) I’ve just used Cheshire to make me forget that JSON is not EDN. Does that count as “manually”?

I’m not sure what your use case exactly is, but jet is a command line tool which can convert EDN to JSON. So you could type EDN in a file and then run jet to convert it.

2 Likes

Actually, that is what jsonista is for, muuntaja is for content negotiation.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.