{"action":"created","issue":{"url":"https://api.github.com/repos/emberjs/data/issues/3955","labels_url":"https://api.github.com/repos/emberjs/data/issues/3955/labels{/name}","comments_url":"https://api.github.com/repos/emberjs/data/issues/3955/comments","events_url":"https://api.github.com/repos/emberjs/data/issues/3955/events","html_url":"https://github.com/emberjs/data/issues/3955","id":119222450,"number":3955,"title":"json-serializer normalizeUsingDeclaredMapping overwrites previous attribute if key is not in map","user":{"login":"jpaas","id":1231716,"avatar_url":"https://avatars.githubusercontent.com/u/1231716?v=3","gravatar_id":"","url":"https://api.github.com/users/jpaas","html_url":"https://github.com/jpaas","followers_url":"https://api.github.com/users/jpaas/followers","following_url":"https://api.github.com/users/jpaas/following{/other_user}","gists_url":"https://api.github.com/users/jpaas/gists{/gist_id}","starred_url":"https://api.github.com/users/jpaas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpaas/subscriptions","organizations_url":"https://api.github.com/users/jpaas/orgs","repos_url":"https://api.github.com/users/jpaas/repos","events_url":"https://api.github.com/users/jpaas/events{/privacy}","received_events_url":"https://api.github.com/users/jpaas/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-11-27T16:39:47Z","updated_at":"2015-12-03T19:45:34Z","closed_at":null,"body":"Have a look here... https://github.com/emberjs/data/blob/e1007db415041ef6a9831b731c9f458d11d2ae4f/addon/serializers/json-serializer.js#L735\r\n\r\n```js\r\n  normalizeUsingDeclaredMapping: function(modelClass, hash) {\r\n    var attrs = get(this, 'attrs');\r\n    var payloadKey, normalizedKey, key;\r\n\r\n    if (attrs) {\r\n      for (key in attrs) {\r\n        payloadKey = this._getMappedKey(key, modelClass);\r\n\r\n        if (!hash.hasOwnProperty(payloadKey)) { continue; }\r\n\r\n        if (get(modelClass, 'attributes').has(key)) {\r\n          normalizedKey = this.keyForAttribute(key);\r\n        }\r\n\r\n        if (get(modelClass, 'relationshipsByName').has(key)) {\r\n          normalizedKey = this.keyForRelationship(key);\r\n        }\r\n\r\n        if (payloadKey !== normalizedKey) {\r\n          hash[normalizedKey] = hash[payloadKey];\r\n          delete hash[payloadKey];\r\n        }\r\n      }\r\n    }\r\n  },\r\n```\r\n\r\nIf I have a payload such as \r\n```json\r\n{\r\n  \"data\": {\r\n    \"attributes\": {\r\n      \"in_my_map\": \"correct\",\r\n      \"not_in_my_map\": \"incorrect\"\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nMy model with end up with a value of \"incorrect\" on the inMyMap property. Why? Because the normalizedKey is not initialized each time through the loop, so it ends up inside the payloadKey != normalizedKey block at the end of the function."},"comment":{"url":"https://api.github.com/repos/emberjs/data/issues/comments/161760554","html_url":"https://github.com/emberjs/data/issues/3955#issuecomment-161760554","issue_url":"https://api.github.com/repos/emberjs/data/issues/3955","id":161760554,"user":{"login":"jpaas","id":1231716,"avatar_url":"https://avatars.githubusercontent.com/u/1231716?v=3","gravatar_id":"","url":"https://api.github.com/users/jpaas","html_url":"https://github.com/jpaas","followers_url":"https://api.github.com/users/jpaas/followers","following_url":"https://api.github.com/users/jpaas/following{/other_user}","gists_url":"https://api.github.com/users/jpaas/gists{/gist_id}","starred_url":"https://api.github.com/users/jpaas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpaas/subscriptions","organizations_url":"https://api.github.com/users/jpaas/orgs","repos_url":"https://api.github.com/users/jpaas/repos","events_url":"https://api.github.com/users/jpaas/events{/privacy}","received_events_url":"https://api.github.com/users/jpaas/received_events","type":"User","site_admin":false},"created_at":"2015-12-03T19:45:34Z","updated_at":"2015-12-03T19:45:34Z","body":"@igorT: In our case we have multiple apps that share the same APIs. One is an administration app that needs all of the attributes of the models in order to edit them. But some of the other apps only care about a few of the attributes and have their own lighter Ember models."}}