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

Automatically repair pasted contents in text mode like in tree mode #177

Open
mariusa opened this issue Oct 26, 2022 · 8 comments
Open

Automatically repair pasted contents in text mode like in tree mode #177

mariusa opened this issue Oct 26, 2022 · 8 comments
Labels
enhancement New feature or request

Comments

@mariusa
Copy link

mariusa commented Oct 26, 2022

At https://www.freeformatter.com/json-formatter.html#before-output
I can paste this

{ age: 22 }

and it will format to add quotes for attributes, eg "age"

Please allow the same for https://jsoneditoronline.org/

@josdejong
Copy link
Owner

josdejong commented Oct 26, 2022

Hi Marius, thanks for your input. https://jsoneditoronline.org/ already has auto repair capability:

After pasting in text mode:

afbeelding

After pasting in tree mode:

afbeelding

Is that what you mean?

@mariusa
Copy link
Author

mariusa commented Oct 26, 2022

Hi Jos, thanks. I see, so one has to paste with Tree mode, not with Text mode, which isn't intuitive.
Would it be possible to auto-repair after pasting within Text mode too?

@josdejong
Copy link
Owner

so one has to paste with Tree mode, not with Text mode, which isn't intuitive.

Not really, all you have to do in text mode is click the big red "Auto repair" button bottom right.

What I find important is that the editor not "automagically" makes changes in content, but that you as a user are in control. It is an interesting idea though to automatically repair contents in text mode too, like in tree mode, as long as there is this clear message at the bottom allowing you to revert the changes and do it yourself. Let me think about it.

@mariusa
Copy link
Author

mariusa commented Oct 26, 2022

click the big red "Auto repair" button bottom right.

Ah, I really missed that! That works, thanks! Feel free to handle as you wish then, or close the issue

@josdejong
Copy link
Owner

Well, I really like your idea. I think normally you paste JSON to do something with it and get it fixed. So if you paste invalid JSON, you will normally always click the "Auto repair" button right after that. So it makes sense to me to automatically "click" the button for you and show a button to undo the repair action instead for the edge cases.

So let me keep this issue open and change the title according to this plan.

@josdejong josdejong added enhancement New feature or request and removed webapp labels Oct 26, 2022
@josdejong josdejong changed the title Allow input without quotes, add quotes automatically Automatically repair pasted contents in text mode like in tree mode Oct 26, 2022
@mariusa
Copy link
Author

mariusa commented Oct 26, 2022

Perfect! Thanks for being open to feedback :)

@drik98
Copy link

drik98 commented Nov 25, 2023

Hey @josdejong I would really appreciate this feature. I currently have the problem that the pasted json content is not recognized as unformatted. I guess because it is not "compact" enough. If it was auto formatted anyway that would resolve this issue.

@josdejong
Copy link
Owner

@drik98 this issue is about auto repair, which is different from auto format. I think it should be configurable, and I can imagine something like an "auto format on save" feature too (not part of the editor but maybe of https://jsoneditoronline.org).

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

No branches or pull requests

3 participants