insertJson5 method

void insertJson5(
  1. String key,
  2. String value
)

Inserts a JSON5 value at the given configuration key path.

JSON5 string values require inner quotes, e.g.:

config.insertJson5('mode', '"peer"');

Throws ZenohException if the key is invalid or the value is rejected. Throws StateError if the config has been disposed or consumed.

Implementation

void insertJson5(String key, String value) {
  _ensureNotDisposed();
  _ensureNotConsumed();
  final nativeKey = key.toNativeUtf8();
  final nativeValue = value.toNativeUtf8();
  try {
    final rc = bindings.zd_config_insert_json5(
      _ptr.cast(),
      nativeKey.cast(),
      nativeValue.cast(),
    );
    if (rc != 0) {
      throw ZenohException(
        'Failed to insert config value for key "$key"',
        rc,
      );
    }
  } finally {
    malloc.free(nativeKey);
    malloc.free(nativeValue);
  }
}