string property

JSONString? get string

转换为一个可能为空的String类型

Implementation

JSONString? get string {
  if (rawValue is JSONDouble) return rawValue.toString();
  if (rawValue is JSONInt) return rawValue.toString();
  if (rawValue is JSONBool) return rawValue.toString();
  if (rawValue is JSONNum) return rawValue.toString();
  if (rawValue is String) return rawValue;
  if (rawValue is JSONArray) return jsonEncode(rawValue);
  if (rawValue is JSONObject) return jsonEncode(rawValue);
  return null;
}