📌  相关文章
📜  检查字符串是否有效 json dart - 任何代码示例

📅  最后修改于: 2022-03-11 14:55:57.460000             🧑  作者: Mango

代码示例1
void main() {
  var jsonString = '{"abc';
  var decodeSucceeded = false;
  try {
    var decodedJSON = json.decode(jsonString) as Map;
    decodeSucceeded = true;
  } on FormatException catch (e) {
    print('The provided string is not valid JSON');
  }
  print('Decoding succeeded: $decodeSucceeded');
}