mergeFromJson method

void mergeFromJson(
  1. String data, [
  2. ExtensionRegistry extensionRegistry = ExtensionRegistry.EMPTY
])

Merges field values from data, a JSON object, encoded as described by GeneratedMessage.writeToJson.

For the proto3 JSON format use: mergeFromProto3Json.

Implementation

void mergeFromJson(String data,
    [ExtensionRegistry extensionRegistry = ExtensionRegistry.EMPTY]) {
  /// Disable lazy creation of Dart objects for a dart2js speedup.
  /// This is a slight regression on the Dart VM.
  /// TODO(skybrian) we could skip the reviver if we're running
  /// on the Dart VM for a slight speedup.
  final Map<String, dynamic> jsonMap =
      jsonDecode(data, reviver: _emptyReviver);
  _mergeFromJsonMap(_fieldSet, jsonMap, extensionRegistry);
}