stringify static method

String stringify(
  1. Object? value
)

Turns value into a JSON String.

A DateTime becomes an ISO 8601 string. Any other object must have a toJson() method. A value with no toJson() throws a JsonUnsupportedObjectError.

JSON.stringify({'name': 'dox'}); // {"name":"dox"}
JSON.stringify({'at': DateTime.utc(2024)}); // {"at":"2024-01-01T00:00:00.000Z"}
JSON.stringify(user); // calls user.toJson()

Implementation

static String stringify(Object? value) {
  return const JsonEncoder(advanceEncode).convert(value);
}