jdorn / json-editor

JSON Schema Based Editor
MIT License
5.8k stars 1.08k forks source link

New properties not shown #524

Open alexbbb opened 8 years ago

alexbbb commented 8 years ago

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 commented 8 years ago

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?

torbensky commented 8 years ago

+1 also having this issue

gmac commented 8 years ago

+1 on this issue.

slow-loris commented 8 years ago

+1

elena89rossi commented 8 years ago

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

radswiat commented 7 years ago

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);
            }
        });`
elena89rossi commented 7 years ago

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

emilb604 commented 6 years ago

+1