valueToJson method

  1. @protected
Object valueToJson(
  1. Object value
)

Implementation

@protected
Object valueToJson(Object value) {
  if (value is int) {
    return value.toDouble();
  }
  if (value is double) {
    if (value.isNaN) {
      return 'nan';
    }
    if (value == double.negativeInfinity) {
      return '-inf';
    }
    if (value == double.infinity) {
      return '+inf';
    }
  }
  if (value is DateTime) {
    return value.toIso8601String().replaceAll(' ', 'T');
  }
  throw ArgumentError.value(value);
}