tryToJson function

Uint8List? tryToJson(
  1. CType type,
  2. dynamic value
)

Implementation

Uint8List? tryToJson(CType type, dynamic value) {
  if ((type is RecordClass ||
          type is VariantClass ||
          (type is TextClass && value is! String)) &&
      // obj may be a map, must be ignore.
      value is! Map) {
    try {
      return type.encodeValue(value.toJson());
    } catch (e) {
      return null;
    }
  }
  return null;
}