operator []= method

  1. @override
void operator []=(
  1. dynamic key,
  2. dynamic value
)
override

Specific implementations which check isImmtable to determine if an unknown key should be allowed.

If isImmutable is false, or the key already exists, then allow the edit. Throw JsonObjectLiteException if we're not allowed to add a new key

Implementation

@override
void operator []=(dynamic key, dynamic value) {
  // If the map is not immutable, or it already contains the key, then
  if (isImmutable == false || containsKey(key)) {
    //allow the edit, as we don't care if it's a new key or not
    _objectData[key] = value;
  } else {
    throw const JsonObjectLiteException('JsonObject is not extendable');
  }
}