json-editor icon indicating copy to clipboard operation
json-editor copied to clipboard

New properties not shown

Open alexbbb opened this issue 10 years ago • 8 comments

When updating JSON schema with new optional properties and then loading a JSON which does not have that optional properties, they are not shown in the editor.

How to reproduce: Go to http://jeremydorn.com/json-editor/ and add this property to the person object's properties in the JSON schema:

    "title": {
      "type": "string",
      "description": "Title"
    },

and then click on "Update Schema"

The new property will be visible in the form and the JSON Output will be refreshed:

{
  "name": "Jeremy Dorn",
  "title": "",
  "age": 25,
  "favorite_color": "#ffa500",
  "gender": "male",
  "location": {
    "city": "San Francisco",
    "state": "CA",
    "citystate": "San Francisco, CA"
  },
  "pets": [
    {
      "type": "dog",
      "name": "Walter"
    }
  ]
}

Delete this from the JSON output and click on "update form":

  "title": "",

Now the "title" property will not be shown anymore. Any ideas on how to solve this issue? Thank you

alexbbb avatar Oct 16 '15 09:10 alexbbb

I've found that one way of making the "title" property come back again in the form is to click on "Properties" and then check the "title" property, but is there a way of doing that programmatically?

alexbbb avatar Oct 16 '15 10:10 alexbbb

+1 also having this issue

torbensky avatar Oct 22 '15 21:10 torbensky

+1 on this issue.

gmac avatar Dec 31 '15 16:12 gmac

+1

slow-loris avatar Aug 03 '16 11:08 slow-loris

if I click on "Properties" and then check the "title" property the property is shown only in Google Chrome , not in Internet Explorer.

elena89rossi avatar Aug 24 '16 08:08 elena89rossi

Quick and temporary solution - remove the line below ( // REMOVED => )

`
setValue: function(value, initial) { var self = this; value = value || {};

        if(typeof value !== "object" || Array.isArray(value)) value = {};

        // First, set the values for all of the defined properties
        $each(this.cached_editors, function(i,editor) {
            // Value explicitly set
            if(typeof value[i] !== "undefined") {
                self.addObjectProperty(i);
                editor.setValue(value[i],initial);
            }
            // Otherwise, remove value unless this is the initial set or it's required
            else if(!initial && !self.isRequired(editor)) {
                // REMOVED => self.removeObjectProperty(i);
            }
            // Otherwise, set the value to the default
            else {
                editor.setValue(editor.getDefault(),initial);
            }
        });`

radswiat avatar Sep 26 '16 22:09 radswiat

I tried to remove the line of code but the property checked is
not yet displayed in IE propertyisnotdisplayed

elena89rossi avatar Sep 27 '16 08:09 elena89rossi

+1

emilb604 avatar Mar 07 '18 18:03 emilb604