Skip to content

v0.5.1 - Default Field Mapping

Latest

Choose a tag to compare

@lmingzhi618 lmingzhi618 released this 03 Aug 03:00

CJM v0.5.1 Release Notes

CJM v0.5.1 is the Default Field Mapping release.

This release makes the normal model-authoring path less repetitive: fields in
CJM-managed structs now default to their exact C++ field names. Explicit JSON
metadata remains available for renames, omitempty, and ignored fields.

The release is intentionally still part of the v0.5 line. It strengthens the
shared field semantics that future runtime backends must consume; it does not
add a new JSON runtime backend.

Highlights

  • Defaults untagged managed fields to their C++ field names
  • Supports json:",omitempty" for default-name optional fields
  • Preserves json:"-" fields in Metadata IR with explicit ignored semantics
  • Diagnoses duplicate effective JSON field names
  • Keeps explicit json:"name" tags as rename overrides
  • Validates normalized field semantics across semantic, nlohmann, contract,
    schema, CLI, CMake, parser, and Tree-sitter fixture tests
  • Updates the basic example to show tag-free same-name fields

Mapping Semantics

For a managed field:

struct User {
    std::string name;
    std::optional<std::string> nickname; // json:",omitempty"
    std::string display_name;            // json:"displayName"
    int internal_id;                     // json:"-"
};

CJM computes:

name         -> "name"
nickname    -> "nickname", omit_empty = true
display_name -> "displayName"
internal_id -> ignored

No case conversion is included in this release. CJM uses exact C++ field names
unless an explicit rename tag is present.

Backend Impact

All backends consume normalized Metadata IR facts:

  • the nlohmann backend emits the same JSON keys whether the field name came from
    a default or an explicit same-name tag
  • the JSON Schema backend uses effective field names and omits ignored fields
  • generated model-contract metadata exposes JSON names, omit_empty, and
    ignored-field status consistently
  • CLI and CMake generation paths use the same semantic pipeline

Backends do not inspect C++ comments or decide default field names themselves.

Known Limitations

Not yet supported:

  • automatic snake_case, camelCase, PascalCase, or acronym conversion
  • type-level opt-in metadata syntax
  • custom converters
  • custom enum string mapping policies
  • runtime JSON Schema validation
  • native JSON backend
  • high-performance runtime backends such as simdjson, Glaze, or yyjson
  • automatic header discovery
  • install/package distribution

Verification

The v0.5.1 release branch was verified locally with:

cmake --build build
ctest --test-dir build --output-on-failure

Expected result:

100% tests passed, 0 tests failed out of 30

Tag

Release tag:

v0.5.1