diff --git a/addon/serializers/json-api.js b/addon/serializers/json-api.js index 093cd348989..10253f42a61 100644 --- a/addon/serializers/json-api.js +++ b/addon/serializers/json-api.js @@ -261,7 +261,7 @@ const JSONAPISerializer = JSONSerializer.extend({ if (resourceHash.attributes) { modelClass.eachAttribute((key) => { let attributeKey = this.keyForAttribute(key, 'deserialize'); - if (resourceHash.attributes.hasOwnProperty(attributeKey)) { + if (resourceHash.attributes[attributeKey] !== undefined) { attributes[key] = resourceHash.attributes[attributeKey]; } }); @@ -307,7 +307,7 @@ const JSONAPISerializer = JSONSerializer.extend({ if (resourceHash.relationships) { modelClass.eachRelationship((key, relationshipMeta) => { let relationshipKey = this.keyForRelationship(key, relationshipMeta.kind, 'deserialize'); - if (resourceHash.relationships.hasOwnProperty(relationshipKey)) { + if (resourceHash.relationships[relationshipKey] !== undefined) { let relationshipHash = resourceHash.relationships[relationshipKey]; relationships[key] = this.extractRelationship(relationshipHash); diff --git a/addon/serializers/json.js b/addon/serializers/json.js index 9c2ee4d0e95..ef4ca3a9bbc 100644 --- a/addon/serializers/json.js +++ b/addon/serializers/json.js @@ -563,7 +563,7 @@ var JSONSerializer = Serializer.extend({ modelClass.eachAttribute((key) => { attributeKey = this.keyForAttribute(key, 'deserialize'); - if (resourceHash.hasOwnProperty(attributeKey)) { + if (resourceHash[attributeKey] !== undefined) { attributes[key] = resourceHash[attributeKey]; } }); @@ -659,7 +659,7 @@ var JSONSerializer = Serializer.extend({ modelClass.eachRelationship((key, relationshipMeta) => { let relationship = null; let relationshipKey = this.keyForRelationship(key, relationshipMeta.kind, 'deserialize'); - if (resourceHash.hasOwnProperty(relationshipKey)) { + if (resourceHash[relationshipKey] !== undefined) { let data = null; let relationshipHash = resourceHash[relationshipKey]; if (relationshipMeta.kind === 'belongsTo') { @@ -685,7 +685,7 @@ var JSONSerializer = Serializer.extend({ } let linkKey = this.keyForLink(key, relationshipMeta.kind); - if (resourceHash.links && resourceHash.links.hasOwnProperty(linkKey)) { + if (resourceHash.links && resourceHash.links[linkKey] !== undefined) { let related = resourceHash.links[linkKey]; relationship = relationship || {}; relationship.links = { related }; @@ -721,7 +721,7 @@ var JSONSerializer = Serializer.extend({ typeClass.eachAttribute((key) => { payloadKey = this.keyForAttribute(key, 'deserialize'); if (key === payloadKey) { return; } - if (!hash.hasOwnProperty(payloadKey)) { return; } + if (hash[payloadKey] === undefined) { return; } hash[key] = hash[payloadKey]; delete hash[payloadKey]; @@ -740,7 +740,7 @@ var JSONSerializer = Serializer.extend({ typeClass.eachRelationship((key, relationship) => { payloadKey = this.keyForRelationship(key, relationship.kind, 'deserialize'); if (key === payloadKey) { return; } - if (!hash.hasOwnProperty(payloadKey)) { return; } + if (hash[payloadKey] === undefined) { return; } hash[key] = hash[payloadKey]; delete hash[payloadKey]; @@ -760,7 +760,7 @@ var JSONSerializer = Serializer.extend({ for (key in attrs) { normalizedKey = payloadKey = this._getMappedKey(key, modelClass); - if (!hash.hasOwnProperty(payloadKey)) { continue; } + if (hash[payloadKey] === undefined) { continue; } if (get(modelClass, 'attributes').has(key)) { normalizedKey = this.keyForAttribute(key); @@ -1273,7 +1273,7 @@ var JSONSerializer = Serializer.extend({ @param {Object} payload */ extractMeta(store, modelClass, payload) { - if (payload && payload.hasOwnProperty('meta')) { + if (payload && payload['meta'] !== undefined) { let meta = payload.meta; delete payload.meta; return meta; @@ -1373,7 +1373,7 @@ var JSONSerializer = Serializer.extend({ typeClass.eachAttribute((name) => { let key = this.keyForAttribute(name, 'deserialize'); - if (key !== name && payload.hasOwnProperty(key)) { + if (key !== name && payload[key] !== undefined) { payload[name] = payload[key]; delete payload[key]; } @@ -1381,7 +1381,7 @@ var JSONSerializer = Serializer.extend({ typeClass.eachRelationship((name) => { let key = this.keyForRelationship(name, 'deserialize'); - if (key !== name && payload.hasOwnProperty(key)) { + if (key !== name && payload[key] !== undefined) { payload[name] = payload[key]; delete payload[key]; } diff --git a/addon/serializers/rest.js b/addon/serializers/rest.js index ceed5088e5e..2093f7680f0 100644 --- a/addon/serializers/rest.js +++ b/addon/serializers/rest.js @@ -816,7 +816,7 @@ var RESTSerializer = JSONSerializer.extend({ var isPolymorphic = relationshipMeta.options.polymorphic; var typeProperty = this.keyForPolymorphicType(key, relationshipType, 'deserialize'); - if (isPolymorphic && resourceHash.hasOwnProperty(typeProperty) && typeof relationshipHash !== 'object') { + if (isPolymorphic && resourceHash[typeProperty] !== undefined && typeof relationshipHash !== 'object') { if (isEnabled("ds-payload-type-hooks")) {