Answers for "check if string is valid json dart"

0

check if string is valid json dart

void main() {
  var jsonString = '{"abc';
  var decodeSucceeded = false;
  try {
    var decodedJSON = json.decode(jsonString) as Map<String, dynamic>;
    decodeSucceeded = true;
  } on FormatException catch (e) {
    print('The provided string is not valid JSON');
  }
  print('Decoding succeeded: $decodeSucceeded');
}
Posted by: Guest on March-17-2021

Code answers related to "check if string is valid json dart"

Browse Popular Code Answers by Language