parse static method

GameLimitsConfig parse(
  1. Object? json
)

Implementation

static GameLimitsConfig parse(Object? json) {
  if (json is! Map) return defaults;
  try {
    final file = _valueOrDefault(json['skinFileMaxBytes'], 1,
        20 * 1024 * 1024, defaults.skinFileMaxBytes);
    final cache = _valueOrDefault(json['skinCacheMaxBytes'], 1024 * 1024,
        1024 * 1024 * 1024, defaults.skinCacheMaxBytes);
    final msg = _valueOrDefault(json['bridgeMessageMaxBytes'], 1024,
        1024 * 1024, defaults.bridgeMessageMaxBytes);
    if (file == null || cache == null || msg == null) return defaults;
    return GameLimitsConfig(
      skinFileMaxBytes: file,
      skinCacheMaxBytes: cache,
      bridgeMessageMaxBytes: msg,
    );
  } catch (_) {
    return defaults;
  }
}