NamingStrategy class abstract interface

Provides a unified interface for field name transformation between Dart-style and JSON-style representations.

The NamingStrategy defines the transformation rules used to map Dart identifiers (typically in camelCase) to JSON-compatible names (such as snake_case or kebab-case) and back.

Overview

Implementations of this interface provide predictable and reversible conversions between internal Dart field names and external JSON keys.

This is a core abstraction used by Jetleaf serialization systems such as JsonMapper, ObjectCodec, and other reflection-based adapters that require naming consistency.

Example

final strategy = SnakeCaseNamingStrategy();

final jsonKey = strategy.toJsonName('userName'); // 'user_name'
final dartField = strategy.toDartName('user_name'); // 'userName'

Common Strategies

  • Snake case (userName → user_name)
  • Kebab case (userName → user-name)
  • Pascal case (userName → UserName)

Implementation Notes

  • Implementations must be deterministic (same input yields same output)
  • The transformation must be reversible (see toDartName)
  • Should handle acronyms, numbers, and edge cases gracefully

See also

Implementers

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDartName(String name) → String
Converts a JSON field name back into a Dart-compatible identifier.
toJsonName(String name) → String
Converts a Dart field name into a JSON-compatible name.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

CLASS → Class<NamingStrategy>
Represents the NamingStrategy type for reflection and framework-level type resolution within the Jetson serialization system.
final