serialize static method
dynamic
serialize(
- Object? value
)
Implementation
static dynamic serialize(Object? value) {
try {
if (value == null) {
return null;
} else if (value is List) {
return value.map((v) => serialize(v)).toList();
} else if (value is Map) {
return Map.fromIterables(
value.keys, value.values.map((v) => serialize(v)));
} else if (value is String) {
return value;
} else if (value is bool) {
return value;
} else if (value is num) {
return value;
} else if (value is DateTime) {
return value.toUtc().toIso8601String();
}
if (value is ApplicationVersionInfo) {
return value.toJson();
}
if (value is BaseRolloutStrategy) {
return value.toJson();
}
if (value is BaseRolloutStrategyAttribute) {
return value.toJson();
}
if (value is FeatureEnvironmentCollection) {
return value.toJson();
}
if (value is FeatureRolloutStrategy) {
return value.toJson();
}
if (value is FeatureRolloutStrategyAttribute) {
return value.toJson();
}
if (value is FeatureState) {
return value.toJson();
}
if (value is FeatureStateUpdate) {
return value.toJson();
}
if (value is FeatureValueType) {
return value.toJson();
}
if (value is RoleType) {
return value.toJson();
}
if (value is RolloutStrategyAttributeConditional) {
return value.toJson();
}
if (value is RolloutStrategyFieldType) {
return value.toJson();
}
if (value is SSEResultState) {
return value.toJson();
}
if (value is StrategyAttributeCountryName) {
return value.toJson();
}
if (value is StrategyAttributeDeviceName) {
return value.toJson();
}
if (value is StrategyAttributePlatformName) {
return value.toJson();
}
if (value is StrategyAttributeWellKnownNames) {
return value.toJson();
}
return value.toString();
} on Exception catch (e, stack) {
throw ApiException.withInner(
500, 'Exception during deserialization.', e, stack);
}
}