Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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');
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #check #string #valid #json #dart
ADD COMMENT
Topic
Name
9+2 =