josdejong / svelte-jsoneditor

A web-based tool to view, edit, format, repair, query, transform, and validate JSON
https://jsoneditoronline.org
Other
814 stars 108 forks source link

Hide part of the document based on a filter #433

Closed DrT27 closed 1 month ago

DrT27 commented 1 month ago

Greetings! I have a problem and am not sure if this feature is already possible or nor implemented yet: I have a complex json object and want to make changes in a filtered state.

  1. Filter the data using the transform button and entering the js snippet to get the reduced, filtered json oɓject.
  2. Edit the resulting data.
  3. Disable/remove the filter to have my original json object including the changes I made.

Point 3 does not work as intended, because any transformed data object becomes the original data object for the next filter/transform. So the original state cannot be reached and transformed data has ireversible losts from the original. Using the undo/redo buttons shows that the package holds temporary derivates of the original object, but changes cannot be passed.

Is it possible to use the jsoneditor for my example or would this need an additional feature?

Please let me know. Best, DrT

josdejong commented 1 month ago

I think what you are looking for is temporarily hide part of the JSON instead of removing (filtering) items from the data. You can indeed not reliably filter, then edit the data, and then revert the filtering (though you can come close by using the .patch() method with immutable-json-patch).

I suppose you're using table mode?

DrT27 commented 1 month ago

Thank you for your quick reply!

The json object I process is not an array alone, although some keys are holding one.

The usage need is as you wrote: hiding parts of it by a filter, to have a better view on the parts that need to be edited.

When you think of programs like Open Office Calc or MS Excel it should behave the same way. Apply a filter - edit - remove the filter.

I think it would be a competitive feature to have similar functionality. Due to the similar icon for the transformator users tend to expect that they can remove a filter again - and are then surprised about lost data.

If this can become a new feature some day I think it could be highly appreciated by many users.