Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce escape/unescape and possibly base64 encode/decode features #405

Open
Tarzan1163 opened this issue Feb 21, 2024 · 3 comments
Open
Labels
enhancement New feature or request webapp

Comments

@Tarzan1163
Copy link

Tarzan1163 commented Feb 21, 2024

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)
@josdejong
Copy link
Owner

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?

@josdejong josdejong added enhancement New feature or request webapp labels Feb 21, 2024
@Tarzan1163
Copy link
Author

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.

@josdejong
Copy link
Owner

Totally clear, thanks for thinking along!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request webapp
Projects
None yet
Development

No branches or pull requests

2 participants