jsonValue property

Future jsonValue

Returns a JSON representation of the object. If the object has a toJSON function, it will not be called.

NOTE The method will return an empty JSON object if the referenced object is not stringifiable. It will throw an error if the object has circular references.

Implementation

Future<dynamic> get jsonValue async {
  if (remoteObject.objectId != null) {
    var response = await executionContext.runtimeApi.callFunctionOn(
        'function() { return this; }',
        objectId: remoteObject.objectId,
        returnByValue: true,
        awaitPromise: true);

    return valueFromRemoteObject(response.result);
  }
  return valueFromRemoteObject(remoteObject);
}