json-editor
json-editor copied to clipboard
Delete Property
General information
- json-editor version: 2.5.4
Expected behavior
An easy way to delete a property or property value.
For example see link below. In our case this has become more noticeable when using format: file
, once you select a photo/picture and save, there is then no easy way to delete the image you uploaded, you need to actually edit the json and remove the base64 contents, which is of course cumbersome. This could apply to any proprty, not just format: file
, I think a simple x
or delete options like are available for arrays
would be useful, or perhaps configurable per property.
Actual behavior
You are unable to delete easilly.
Steps to reproduce the behavior
Direct link to example: https://json-editor.github.io/json-editor/?data=N4Ig9gDgLglmB2BnEAuUMDGCA2MBGqIAZglAIYDuApomALZUCsIANOHgFZUZQD62ZAJ5gArlELwwAJzplsrEIgwALKrNShYUbFUIAFKlNrwFUQRF0p2XHgqlUAjiJj2AJqgDaIeGQYKIUmBEMDq8EJggALpsAZCGsDQa3r6WmuaWilBSMPAA5gquNBjZ0HAmVgBiLohQAARk8K61ADJkNbU+fmx0Oc1UeVDKqAAsbIVEZCLY4lYAUoZqgrUAItImAL4xgcGh4RhJJDJkM8Qhut1UrjBkSXg5ZFKCAKLwWFd5hHhtVABswyCbEBmCyEGrZD7rSFsRDKMAUXiGQJGQg5KCGMg8MqmVR+Kx4MBgKBgsgQf6QoA=
{
"title": "Person",
"type": "object",
"required": [
"name",
"profile_pic"
],
"properties": {
"name": {
"type": "string",
"description": "First and Last name",
"minLength": 4,
"default": "Jeremy Dorn"
},
"profile_pic": {
"format": "file",
"media": {
"binaryEncoding": "base64"
},
"type": "string"
}
}
}
I have been looking for this for a long time. Hope this gets fixed soon.
PRs welcome
@bhagyamudgal no objections from me
@kane-mason just a general question: why is profile_pic
required
when you can (should be able to) delete it?
But a PR would be nice anyway.
@schmunk42 it is not atually required, was just for visiblity on the test case
@kane-mason Because with show_opt_in
and required: false
you could achieve a similar behaviour.
@schmunk42 i did not know that! Thanks!
@schmunk42 following on your comment, is there a way to display certain properties that are not necessarilly required? show_opt_in
shows all non-required properties, i am looking for a way to show certain ones
This is a logical problem with json-schema, IMO.
Eg.
- how would you display an empty string and which json should be generated (empty string or nothing)?
- how would you display an empty integer without default value (0, empty string, nothing)?
@schmunk42 is this not similar to show_opt_in
? How does that do it?
Just to make sure we on the same page my idea is, like the required
array, to have an optional
(can be named more appropriately) array.
In the way I, and im sure others use this package, is like a form to capture information. Like many forms some fields are required and some not, but i still want the optional fields to be displayed and up to the user to fill in or not. However i do not want to display allll non required fields as some are not meant to be visible to user, etc timestamps and other generated information.
I made an example with show_opt_in
set to true, required, optional, hidden and visible properties that could answer your question: example
@germanbisurgi @schmunk42 that is very useful, thanks!
The only problem (and it might be a bug?) is that there is no way to unhide the properties in the ui? If you click the properties dropdown, the hidden properties are selected (should be unselected maybe?) and toggling that box has no effect. Maybe i am misunderstanding but would be nice to show the hidden properties in the ui if you need to
@kane-mason Actually I thought hidden properties in the example are hidden-inputs, but they are just hidden by CSS.
So you could make them visible, but I think they shold be type="hidden"
.
Not sure how to proceed here. CC: @germanbisurgi
You can set the editor's "format": "hidden"
to render inputs type hidden like in this updated example
I think that we are discussing something totally different that the original topic :-)
Created a separate issue for our discussion.