{"action":"created","issue":{"url":"https://api.github.com/repos/JamesNK/Newtonsoft.Json/issues/931","repository_url":"https://api.github.com/repos/JamesNK/Newtonsoft.Json","labels_url":"https://api.github.com/repos/JamesNK/Newtonsoft.Json/issues/931/labels{/name}","comments_url":"https://api.github.com/repos/JamesNK/Newtonsoft.Json/issues/931/comments","events_url":"https://api.github.com/repos/JamesNK/Newtonsoft.Json/issues/931/events","html_url":"https://github.com/JamesNK/Newtonsoft.Json/issues/931","id":158732896,"number":931,"title":"Handling duplicate elements in JSON payload","user":{"login":"dmoeff","id":6855115,"avatar_url":"https://avatars.githubusercontent.com/u/6855115?v=3","gravatar_id":"","url":"https://api.github.com/users/dmoeff","html_url":"https://github.com/dmoeff","followers_url":"https://api.github.com/users/dmoeff/followers","following_url":"https://api.github.com/users/dmoeff/following{/other_user}","gists_url":"https://api.github.com/users/dmoeff/gists{/gist_id}","starred_url":"https://api.github.com/users/dmoeff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmoeff/subscriptions","organizations_url":"https://api.github.com/users/dmoeff/orgs","repos_url":"https://api.github.com/users/dmoeff/repos","events_url":"https://api.github.com/users/dmoeff/events{/privacy}","received_events_url":"https://api.github.com/users/dmoeff/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-06-06T17:37:15Z","updated_at":"2016-06-07T02:15:58Z","closed_at":"2016-06-06T21:28:18Z","body":"What is the best way with Json.NET to restrict occurrence of duplicate elements in JSON payload?\r\nFor example:\r\n {\r\n    \"role\" : \"default\",\r\n    \"username\" : \"mallory\",\r\n    \"role\": \"admin\",\r\n    \"password\" : \"Evil123!\"\r\n}"},"comment":{"url":"https://api.github.com/repos/JamesNK/Newtonsoft.Json/issues/comments/224146205","html_url":"https://github.com/JamesNK/Newtonsoft.Json/issues/931#issuecomment-224146205","issue_url":"https://api.github.com/repos/JamesNK/Newtonsoft.Json/issues/931","id":224146205,"user":{"login":"dmoeff","id":6855115,"avatar_url":"https://avatars.githubusercontent.com/u/6855115?v=3","gravatar_id":"","url":"https://api.github.com/users/dmoeff","html_url":"https://github.com/dmoeff","followers_url":"https://api.github.com/users/dmoeff/followers","following_url":"https://api.github.com/users/dmoeff/following{/other_user}","gists_url":"https://api.github.com/users/dmoeff/gists{/gist_id}","starred_url":"https://api.github.com/users/dmoeff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmoeff/subscriptions","organizations_url":"https://api.github.com/users/dmoeff/orgs","repos_url":"https://api.github.com/users/dmoeff/repos","events_url":"https://api.github.com/users/dmoeff/events{/privacy}","received_events_url":"https://api.github.com/users/dmoeff/received_events","type":"User","site_admin":false},"created_at":"2016-06-07T02:15:58Z","updated_at":"2016-06-07T02:15:58Z","body":"            try\r\n            {\r\n                var message =   \"{\" +\r\n                                    \"\\\"DeviceAdded\\\" :\" + \r\n\t                                \"{\" +\r\n                                        \"\\\"DeviceId\\\" : \\\"SN123456\\\",\" +\r\n                                        \"\\\"Protocols\\\" : [],\" +\r\n                                        \"\\\"DeviceType\\\" : \\\"UPS\\\",\" +\r\n                                        \"\\\"Model\\\" : \\\"12345\\\",\" +\r\n                                        \"\\\"HardwareVersion\\\" : \\\"1.0.0.0\\\",\" +\r\n                                        \"\\\"FirmwareVersion\\\" : \\\"2.0.0.0\\\",\" +\r\n                                        \"\\\"SoftwareVersion\\\" : \\\"3.0.0.0\\\",\" +\r\n                                        \"\\\"SerialNumber\\\" : \\\"1\\\",\" +\r\n                                        \"\\\"SerialNumber\\\" : \\\"456\\\"\" +\r\n                                    \"}\" +\r\n                                \"}\";\r\n\r\n                var jobj = JsonConvert.DeserializeObject<JObject>(message);\r\n                Console.WriteLine(jobj);\r\n            }\r\n            catch (Exception ex)\r\n            {\r\n                Console.WriteLine(ex.GetType());\r\n                Console.WriteLine(ex.Message);\r\n            }\r\n\r\nIf I use Newtonsoft.Json 6.0.8 I get exception System.ArgumentException: Can not add property SerialNumber to Newtonsoft.Json.Linq.JObject. Property with the same name already exists on object.\r\n\r\nIf I use Newtonsoft.Json 8.0.2 the code executes without error. What changed between these two versions? How with Newtonsoft.Json 6.0.8 I can get the same behavior as with Newtonsoft.Json 6.0.8?\r\n"}}
{"actor":{"display_login":"dmoeff"}}