Template Struct OpaqueObjectField

Struct Documentation

template<class Class>
struct OpaqueObjectField

Binds a JSON key to a nlohmann::json struct member that carries an “any-JSON-object whose shape is runtime-dependent” payload.

Visitor behaviour:

  • JsonWriter - writes the member value as-is (no introspection / no type tagging).

  • JsonReader - accepts any JSON object value; rejects scalars, arrays, and null with a FieldError; absent fields leave the member at its default (empty object).

  • SchemaWriter - emits {type:object, additionalProperties:true, x-medkit-opaque:true} and marks the field required (opaque fields are not wrapped in std::optional).

Use for fields whose shape depends on runtime context: live ROS message payloads, action results, plugin-provided data. NEVER brace-initialize directly - construct via the opaque_object() factory.

Public Types

using opaque_object_tag = void

Detection tag picked up by is_opaque_object_field SFINAE.

Public Members

std::string_view key
nlohmann::json Class::* ptr