josdejong / svelte-jsoneditor

A web-based tool to view, edit, format, repair, query, transform, and validate JSON

Home Page:https://jsoneditoronline.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Introduce escape/unescape and possibly base64 encode/decode features

Tarzan1163 opened this issue · comments

While working with JSON, it is often copied from logs or any kind of outputs, and also inserted into configurations or variables.
Because of that, it would be very helpful to have at least escape/unescape features integrated into JSON Editor Online instead of using 3rd party software.
It would be also beneficial to introduce simple base64 encode/decode features as JSON often represents binary payload in all kinds of communications.

I propose simple combo box with several items (operations) that would take currently entered text, perform selected operation and copy result to clipboard:

  • escape
  • unescape
  • encode (base64)
  • decode (base64)

Thanks for your inputs. That can be interesting indeed.

Some thoughts:

  1. Right now, the editor can already unescape an escaped string. This is presented as a "repair" option. In the same spirit, we could detect a base64 encoded string and offer to decode that.
  2. We can quite easily add an "Copy base64" option to the "Copy" menu (there is already a "Copy escaped" option there). Does that make sense?
  3. I think your idea is to add a new button "Convert" say right from the Sort and Transform buttons. A difficulty with that is that if you would click "convert to base64", the editor shows big red warnings because the text is not valid JSON. So we either need to extend the editor with some new "mode", having it understand that this is escaped text and all is alright, or otherwise we should avoid this by only having a "Copy to base64" option (not showing the base64 text in the editor). The latter would be easier.

Any thoughts on that?

Wow, first thanks for such fast reply.

  1. If you would be able to decode base64 in the same manner as escaped json, then that would certainly do the work.
  2. That is actually what i ment, to add copy option without altering the text itself.
  3. I quess that ideal of having specialized menu button, e.g. "Convert" just seemd to be more clear to me. Like you know, that inserted json is correct, but only escaped/base64 encoded. This repair feature feels a bit (how to put it correctly) "aggresive". Meaning that if i will have a very long document, then it makes me feel that it could alter the document in some way. but i will not be able to check it due its length. Maybe its just nitpicking, i know it works fine, but having at least "Unescape", "Decode" and "Repair" text would seem to be much cleaner because you know exactly whould it will do, but its the same problem with recognizing the content.

Totally clear, thanks for thinking along!