CodeSampleX

Sample

json_annotation 4.9.0: Configure JsonSerializable options and enum decoding fallbacks in json_annotation, proving snake_case key enforcement, unknownEnumValue null bypass, and readValue error attribution

Verified sample for pub json_annotation 4.9.0: Configure JsonSerializable options and enum decoding fallbacks in json_annotation, proving snake_case key…

sha256:eabf9843a09e0a2fac2d9fe9f0df3eebd2f3eef2bf42bdd99120e6754d499267

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
2
Signing keys that built it
2
Declared environment dart linux x64 dart dart pub

Verification-run environments

Environment Contract Stages Run
dart 3 · linux debian/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · pub@1
2026-08-17
dart 3 · linux debian/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · pub@1
2026-08-18

Case

HOW
Goal
Configure JsonSerializable options and enum decoding fallbacks in json_annotation, proving snake_case key enforcement, unknownEnumValue null bypass, and readValue error attribution
Packages
Symbols
  • JsonSerializable
  • JsonSerializable.fromJson
  • FieldRename
  • JsonKey.unknownEnumValue
  • JsonKey.nullForUndefinedEnumValue
  • JsonKey.readValue
  • $enumDecode
  • $enumDecodeNullable
  • $checkedCreate
  • $checkedConvert
  • $checkKeys
  • CheckedFromJsonException
  • UnrecognizedKeysException
  • MissingRequiredKeysException
  • DisallowedNullValueException
Environment
dart
Created
2026-08-17T14:38:30Z

Contract

  1. JsonSerializable.fromJson enforces snake_case option keys and disallowUnrecognizedKeys, throwing a CheckedFromJsonException with badKey true on camelCase Dart property names
  2. field_rename configuration parses exact enum string identifiers and throws an ArgumentError wrapped in CheckedFromJsonException on non-matching strings like screaming_snake
  3. $enumDecodeNullable returns the unknownValue fallback for unrecognized wire strings but returns null when the input is null, while non-nullable $enumDecode throws ArgumentError on null inputs even when unknownValue is provided
  4. JsonKey.nullForUndefinedEnumValue causes $enumDecodeNullable to map unrecognized wire strings to null, but passing an incompatible enum type throws an ArgumentError
  5. readValue custom extractors allow retrieving values from nested paths or aliases, and type mismatch exceptions are re-attributed to the target model field key in CheckedFromJsonException
  6. $checkKeys evaluates allowedKeys first, requiredKeys second, and disallowNullValues last, where disallowNullValues ignores completely absent keys unless combined with requiredKeys
  7. $checkedNew attaches the failing key name to CheckedFromJsonException for missing and disallowed-null keys, but leaves key as null for UnrecognizedKeysException

Files

  • NOTES.md
  • csx.json
  • lib/account_config.dart
  • pubspec.lock
  • pubspec.yaml
  • test/contract.dart

Download the source artifact (tar.gz)

Origin Seeder

csx-seed