{
  "id": 20070273,
  "title": "Obfuscating a Polymorphic JSON Contract: Why [JsonDerivedType] Survives Renaming and TypeNameHandling Does Not",
  "url": "https://urgent.news/2026/11/14/obfuscating-a-polymorphic-json-contract-why-jsonderivedtype-survives",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-14T23:10:17.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/zero_heartbeat_06a3625d7a/obfuscating-a-polymorphic-json-contract-why-jsonderivedtype-survives-renaming-and-45am"
  },
  "original_language": "en",
  "account": "Renaming does not impact System.Text.Json's [JsonDerivedType] serialization, whereas Newtonsoft's TypeNameHandling does. With System.Text.Json, the wire format remains unchanged even after type renaming. To obfuscate a type hierarchy without relying on a single name, use opaque, intentional discriminators chosen as a wire vocabulary, rather than deriving them from the identifier. This approach ensures that even after obfuscation, the wire format remains identical and can be deserialized without issue.",
  "summary": "Property-level renaming breaks are annoying but shallow: a key comes out wrong, you pin it with [JsonPropertyName] , done. Polymorphic serialization is a deeper hazard, because the thing that goes on the wire is not a property name — it is the identity of the type itself . Obfuscation exists to destroy that identity. So a polymorphic contract is exactly the place where \"renaming broke…",
  "key_points": [
    "System.Text.Json maintains wire format despite [JsonDerivedType] renaming",
    "TypeNameHandling in Newtonsoft affects serialized [JsonDerivedType]",
    "Opaque discriminators provide effective type hierarchy obfuscation"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}