DamienCassou / json-navigator

View and navigate JSON structures
GNU General Public License v3.0
148 stars 6 forks source link

Question/Feature request: Could json-navigator edit json files? #19

Open D4N opened 4 years ago

D4N commented 4 years ago

First and foremost: this package is awesome! Finally I can keep my sanity when viewing large package.json files. Thank you for creating it!

What would make it even more useful, would be the ability to edit nodes. Is this maybe already possible? If not, would it be possible to add this?

DamienCassou commented 4 years ago

Thanks for your kind words. There is nothing in place to edit json documents and I don't plan to implement anything like this. Feel free to give it a try and send a PR though.

landakram commented 2 years ago

Sort of related to this, is it possible to jump from the json-navigator buffer to the node/value under point in the original buffer? I didn't see a way to do this, but I could have just missed it. That would solve the "edit" functionality for me in a quick and easy way.

If it's not possible, does json-navigator / hierarchy store any hints/source information that might make this functionality easier to implement? I'd be happy to attempt an implementation

DamienCassou commented 2 years ago

Sort of related to this, is it possible to jump from the json-navigator buffer to the node/value under point in the original buffer?

There is no such feature.

If it's not possible, does json-navigator / hierarchy store any hints/source information

hierarchy allows you to store whatever you want in the hierarchy. But you would have to rewrite json-navigator as it currently doesn't store such information. The code of json-navigator is small and hopefully easy to read and understand so you might give it a try.

afidegnum commented 2 years ago

I'm also interested in this project. Is there a way to click on the leaf node to open a new window so it will make JSON editing easier ? Once done editing, we can programmatically close an save the edited JSON node, and reload the new modification

DamienCassou commented 2 years ago

there is no such feature.

afidegnum commented 2 years ago

could it be inside the hierarchy package?

DamienCassou commented 2 years ago

Maybe part of the feature could indeed be implemented in the hierarchy package.

afidegnum commented 2 years ago

ok, I have been reading through the code of the hierarchy package, I will be grateful if you can guide me through a bit.

Should I open a new issue or I can continue here?

Motivation:

I have an established JSON tree, I only want to edit additional properties from their leaf nodes.

i.e before

'{"name":"John", "age":30}'

and when I click on the leaf node of name, I need to open a new window so i can have more room to add additonal property as

'{"name":"John", "age":30, "profession":"programmer"}' Then I can post the update via Rest API which I already established.

to make work easier, I only need to select a leaf node and perform the update.

I have identified a few functions, I don't know if I'm on the right path:

hierarchy-labelfn-button-if and hierarchy-labelfn-button so in this case, I wanted to open a new window and edit the JSON property if the JSON node is a leaf node.

I'm looking at extending the hierarchy-labelfn-button-if using emacs-noflet but I'm still a bit confused, I will be grateful if you can give some hints to guide me on the path

DamienCassou commented 2 years ago

@afidegnum what you are asking for seems quite different from the initial message. I suggest creating a new issue maybe someone will help you.

afidegnum commented 2 years ago

Thanks,