{"action":"created","issue":{"url":"https://api.github.com/repos/mgholam/fastJSON/issues/106","repository_url":"https://api.github.com/repos/mgholam/fastJSON","labels_url":"https://api.github.com/repos/mgholam/fastJSON/issues/106/labels{/name}","comments_url":"https://api.github.com/repos/mgholam/fastJSON/issues/106/comments","events_url":"https://api.github.com/repos/mgholam/fastJSON/issues/106/events","html_url":"https://github.com/mgholam/fastJSON/issues/106","id":490131575,"node_id":"MDU6SXNzdWU0OTAxMzE1NzU=","number":106,"title":"Serialise / Deserialise Issue","user":{"login":"MTantos1","id":54972506,"node_id":"MDQ6VXNlcjU0OTcyNTA2","avatar_url":"https://avatars3.githubusercontent.com/u/54972506?v=4","gravatar_id":"","url":"https://api.github.com/users/MTantos1","html_url":"https://github.com/MTantos1","followers_url":"https://api.github.com/users/MTantos1/followers","following_url":"https://api.github.com/users/MTantos1/following{/other_user}","gists_url":"https://api.github.com/users/MTantos1/gists{/gist_id}","starred_url":"https://api.github.com/users/MTantos1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MTantos1/subscriptions","organizations_url":"https://api.github.com/users/MTantos1/orgs","repos_url":"https://api.github.com/users/MTantos1/repos","events_url":"https://api.github.com/users/MTantos1/events{/privacy}","received_events_url":"https://api.github.com/users/MTantos1/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2019-09-06T05:07:11Z","updated_at":"2019-09-27T12:49:23Z","closed_at":null,"author_association":"NONE","body":"I have a class I'm trying to serialise and then deserialise using your library and it throws an InvalidCastException when trying to Deserialise the following json\r\n```\r\n[\r\n  {\r\n    \"$types\": {\r\n      \"Common.Lib.LibAddress, LibCommon, Version=1.0.7.0, Culture=neutral, PublicKeyToken=null\": \"1\",\r\n      \"Common.Lib.LibSuburb, LibCommon, Version=1.0.7.0, Culture=neutral, PublicKeyToken=null\": \"2\"\r\n    },\r\n    \"$type\": \"1\",\r\n    \"Street\": \"PO Box 2034\",\r\n    \"TheSuburb\": {\r\n      \"$type\": \"2\",\r\n      \"Name\": \"\",\r\n      \"Postcode\": \"\",\r\n      \"State\": \"\",\r\n      \"City\": \"\",\r\n      \"Source\": \"\",\r\n      \"IsDeleted\": false,\r\n      \"TimeStamp\": \"2014-01-31T00:15:31Z\",\r\n      \"Id\": \"201\"\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"201\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2014-01-31T00:15:31Z\",\r\n    \"Id\": \"540\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"PO BOX 260\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"309\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2014-01-31T00:15:32Z\",\r\n    \"Id\": \"1393\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"43 Lerra Road,\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"436\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2014-01-31T00:15:33Z\",\r\n    \"Id\": \"363\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"Brixentaler Strasse 24 Hopfgarten Im Brixental\\r\\nAUSTRIA 6361\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"835\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2017-08-02T21:06:32Z\",\r\n    \"Id\": \"1980\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"9 Quokka Court\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"835\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2016-11-16T05:22:12Z\",\r\n    \"Id\": \"3194\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"PO Box 4884\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"900\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2015-05-27T23:09:09Z\",\r\n    \"Id\": \"2198\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"Suite 11, Level 1, 1410 Logan Road\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"1027\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2016-04-05T05:29:22Z\",\r\n    \"Id\": \"2613\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"1 Hill Street\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"1037\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2016-04-27T00:16:19Z\",\r\n    \"Id\": \"2648\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"Unit 116, Grand Mariner, 12 Commodore Drive\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"1038\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2016-04-28T23:11:40Z\",\r\n    \"Id\": \"2650\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"\\\"Grand Mariner\\\"\\r\\nUnit 116\\r\\n12 Commodore Drive\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"1038\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2016-05-23T01:05:04Z\",\r\n    \"Id\": \"2712\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"\\\"Grand Mariner\\\"\\r\\nUnit 116,  12 Commodore Drive\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"1038\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2016-05-24T02:40:34Z\",\r\n    \"Id\": \"2715\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"42 Beacon Hill Road\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"1044\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2016-05-02T06:35:25Z\",\r\n    \"Id\": \"2664\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"8503 Forest Lane\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"1214\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2017-02-28T21:47:09Z\",\r\n    \"Id\": \"3398\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"Suite 2.2, 6 Reliance Drive\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"1233\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2017-03-27T00:32:35Z\",\r\n    \"Id\": \"3501\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"Suite 2.2, 6 Reliance Drive\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"1233\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2017-03-27T00:32:42Z\",\r\n    \"Id\": \"3502\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"42 Macquarie Street\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"1251\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2017-05-02T05:06:11Z\",\r\n    \"Id\": \"3582\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"131 McIlwraith Street\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"1267\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2017-05-22T06:41:35Z\",\r\n    \"Id\": \"3636\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"131 McIlwraith Street\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"1267\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2017-05-22T06:41:35Z\",\r\n    \"Id\": \"3637\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"130 Gould Rd\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"1280\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2017-05-30T23:02:20Z\",\r\n    \"Id\": \"3683\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"130 Gould Rd\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"1280\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2017-05-30T23:02:20Z\",\r\n    \"Id\": \"3684\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"54 Waverley Rd\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"1288\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2017-06-08T06:28:18Z\",\r\n    \"Id\": \"3710\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"10A Holroyd Avenue\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"1286\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2017-06-07T23:19:55Z\",\r\n    \"Id\": \"3702\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"10A Holroyd Avenue\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"1286\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2017-06-07T23:19:55Z\",\r\n    \"Id\": \"3703\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"Unit 6, 288 Swann Rd\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"1319\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2017-07-11T02:44:40Z\",\r\n    \"Id\": \"3825\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"Unit 6, 288 Swann Rd\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 2\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"1319\",\r\n    \"Suburb\": \"\",\r\n    \"Postcode\": \"\",\r\n    \"State\": \"\",\r\n    \"City\": \"\",\r\n    \"TimeStamp\": \"2017-07-11T02:44:40Z\",\r\n    \"Id\": \"3826\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"__No Address__\",\r\n    \"TheSuburb\": {\r\n      \"$type\": \"2\",\r\n      \"Name\": \" \",\r\n      \"Postcode\": \"    \",\r\n      \"State\": \"   \",\r\n      \"City\": \"_Over Seas_\",\r\n      \"Source\": \"\",\r\n      \"IsDeleted\": false,\r\n      \"TimeStamp\": \"2014-03-10T02:53:24Z\",\r\n      \"Id\": \"457\"\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"457\",\r\n    \"Suburb\": \" \",\r\n    \"Postcode\": \"    \",\r\n    \"State\": \"   \",\r\n    \"City\": \"_Over Seas_\",\r\n    \"TimeStamp\": \"2014-03-10T02:53:24Z\",\r\n    \"Id\": \"1619\"\r\n  },\r\n  {\r\n    \"$type\": \"1\",\r\n    \"Street\": \"1205 Falls Bridge Dr\\r\\nRALEIGH NC 27614 USA\",\r\n    \"TheSuburb\": {\r\n      \"$i\": 28\r\n    },\r\n    \"IsDeleted\": false,\r\n    \"SuburbId\": \"457\",\r\n    \"Suburb\": \" \",\r\n    \"Postcode\": \"    \",\r\n    \"State\": \"   \",\r\n    \"City\": \"_Over Seas_\",\r\n    \"TimeStamp\": \"2014-05-05T04:11:19Z\",\r\n    \"Id\": \"1694\"\r\n  }\r\n]\r\n```\r\nFrom what I can see the library appears to be reducing output by using an internal dictionary to serialise \"Equal\" objects as `\"$i\": n`. Based on this assumption the final Address in the json array has a Suburb (replaced by \"$i\": 28) which throws an InvalidCastException `Unable to cast object of type 'Common.Lib.Address' to type 'Common.Lib.Suburb'.`\r\n\r\nThe interface for Address and Suburb are as follows:\r\n```\r\npublic class Address {\r\n    public string Street { get; set; }\r\n    public Suburb TheSuburb { get; set; }\r\n    public bool IsDeleted { get; set; }\r\n    public string SuburbId { get; set; }\r\n    public string Suburb { get; set; }\r\n    public string Postcode { get; set; }\r\n    public string State { get; set; }\r\n    public string City { get; set; }\r\n    public DateTime? TimeStamp { get; set; }\r\n    public string Id { get; set; }\r\n}\r\n\r\npublic class Suburb {\r\n    public string Name { get; set; }\r\n    public string Postcode { get; set; }\r\n    public string State { get; set; }\r\n    public string City { get; set; }\r\n    public string Source { get; set; }\r\n    public bool IsDeleted { get; set; }\r\n    public DateTime? TimeStamp { get; set; }\r\n    public string Id { get; set; }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/mgholam/fastJSON/issues/comments/535925130","html_url":"https://github.com/mgholam/fastJSON/issues/106#issuecomment-535925130","issue_url":"https://api.github.com/repos/mgholam/fastJSON/issues/106","id":535925130,"node_id":"MDEyOklzc3VlQ29tbWVudDUzNTkyNTEzMA==","user":{"login":"mgholam","id":460565,"node_id":"MDQ6VXNlcjQ2MDU2NQ==","avatar_url":"https://avatars1.githubusercontent.com/u/460565?v=4","gravatar_id":"","url":"https://api.github.com/users/mgholam","html_url":"https://github.com/mgholam","followers_url":"https://api.github.com/users/mgholam/followers","following_url":"https://api.github.com/users/mgholam/following{/other_user}","gists_url":"https://api.github.com/users/mgholam/gists{/gist_id}","starred_url":"https://api.github.com/users/mgholam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgholam/subscriptions","organizations_url":"https://api.github.com/users/mgholam/orgs","repos_url":"https://api.github.com/users/mgholam/repos","events_url":"https://api.github.com/users/mgholam/events{/privacy}","received_events_url":"https://api.github.com/users/mgholam/received_events","type":"User","site_admin":false},"created_at":"2019-09-27T12:49:23Z","updated_at":"2019-09-27T12:49:23Z","author_association":"OWNER","body":"fixed in v2.2.6 behind `JSONParameters.OverrideObjectHashCodeChecking = true`"}}
{"actor":{"display_login":"mgholam"}}