Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/editors/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({
if(this.jsoneditor.options.remove_empty_properties || this.options.remove_empty_properties) {
for(var i in result) {
if(result.hasOwnProperty(i)) {
if(typeof result[i] === 'undefined' || result[i] === '') delete result[i];
if(typeof result[i] === 'undefined' || result[i] === '' || Object.keys(result[i]).length == 0 && result[i].constructor == Object) delete result[i];

@dexif dexif Apr 28, 2017

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong logic. It's should be...
Oh... And you should check if result[i] == null

if(typeof result[i] === 'undefined' || result[i] === '' || (result[i] !== null && Object.keys(result[i]).length == 0 && result[i].constructor == Object)) delete result[i];

}
}
}
Expand Down