Join our Newsletter — 33% off our NHI Course
Home› Glossary› Cyber Security› SerializedName
Cyber Security

SerializedName

← Back to Glossary
By NHI Mgmt Group Updated October 31, 2026 Domain: Cyber Security

SerializedName is a GSON annotation that assigns a fixed JSON field name to a Java or Kotlin member. It is used when the original source name may change during obfuscation or refactoring. For enums, it also stabilises the string value written into and read from JSON payloads.

What SerializedName does in JSON binding

SerializedName lets a Gson model bind a Java or Kotlin member to a fixed JSON field name, even if the source symbol is renamed during obfuscation or refactoring. For enums, it also stabilises the exact string written to and read from JSON, which helps keep payload contracts consistent across builds.

This is a naming control, not a data-transform feature. The annotation does not change object structure or validation rules, but it does make the external JSON contract independent of implementation details inside the codebase.

Why fixed field names matter for API compatibility

JSON consumers often depend on stable field names, especially when payloads cross service boundaries, mobile clients, or long-lived integrations. If a class member is renamed in source code without a fixed external name, serialisation can silently break compatibility or produce different wire values after a refactor or obfuscation step.

With enums, the risk is sharper because the value itself may be treated as a protocol token. A renamed enum constant can alter both outgoing JSON and inbound parsing unless the application pins the external string explicitly with OWASP API Security Top 10 guidance in mind, since broken authentication and authorisation issues often begin with unstable request or response handling.

How SerializedName supports refactoring and obfuscation

Mobile apps, SDKs and Java services are often refactored for readability, modularity or code shrinking. Without a fixed serialized name, the external JSON representation becomes coupled to the internal symbol name, so harmless source changes can become breaking API changes. SerializedName decouples the wire format from the implementation symbol and reduces that fragility.

This is especially useful when generated or shrinked builds are part of the delivery pipeline. The annotation preserves a stable contract even if tooling rewrites member names, which means the application can evolve internally without forcing every downstream JSON consumer to change at the same time.

Practical usage and trade-offs

SerializedName is most valuable when the JSON field name must remain stable for compatibility, versioning or interoperability. It is less useful when a project treats JSON as a purely internal format, because the main benefit comes from protecting the boundary between implementation and external data exchange.

One practical trade-off is governance over naming. Once a fixed serialized name is published, it becomes part of the contract and should be treated as deliberately chosen API surface. That helps avoid accidental drift, but it also means teams need a change process for updating names when a contract really does need to evolve.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP API Security Top 10 addresses the attack and risk surface, while NIST SP 800-53 Rev 5 and CIS Controls v8 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP API Security Top 10API8 — Security MisconfigurationSerializedName helps prevent wire-format drift from implementation renaming.
Recommendation — Pin externally visible JSON names to avoid contract-breaking misconfiguration during refactors.
NIST SP 800-53 Rev 5SA-11 — Developer Testing and EvaluationStable serialisation contracts need verification during build and change control.
Recommendation — Test that renamed members still serialise to the intended field names.
CIS Controls v8CIS-16 — Application Software SecurityApplication security practice should preserve stable data contracts across software changes.
Recommendation — Review application changes for compatibility-impacting serialization name changes.

Practitioner Guidance

Why practitioners should care: Use SerializedName when the JSON name must survive refactoring, obfuscation or enum renaming without changing the wire contract. That is a small annotation with a large compatibility payoff, especially in client-facing APIs and long-lived payload schemas.

Common misunderstanding: The annotation does not make a model “safer” by itself. It simply pins the serialised field name, so security and correctness still depend on validation, schema discipline and the surrounding API controls.

Practitioner takeaway: Treat annotated field names as part of the public contract and review them with the same care you would give any externally visible API element.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on October 31, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org