safe_json 1.0.4 copy "safe_json: ^1.0.4" to clipboard
safe_json: ^1.0.4 copied to clipboard

A happy way to parse JSON in Dart which can avoid crush and show error detail in console. Primary purpose of this library is to find out backend error(incomplete data) at the first time.

safe_json #

License

Small, easy to use null safety json decoding library. The primary goal of this library is to find out bugs in the early stages of development when parsing JSON values.

Features #

  • Safely parse JSON values to various data types.
  • Provide default values when parsing fails.
  • Error logging with file location.

Examples #

final name = json.safeString('name', defaultValue: 'John');

final age = json.safeInt('age');

final articles = json.safeList<String>('articles');

final vehicles = json.safeList<Vehicle>('vehicles', itemParse: (json) => Vehicle.fromJson(json));

//set to true if want to disable error logging (usually in production)
SafeJsonLibrary.skipLog = true; 

Console Logs #

Installation #

Add safe_json to your pubspec.yaml file:

dependencies:
  safe_json: ^1.0.1
1
likes
0
points
76
downloads

Publisher

unverified uploader

Weekly Downloads

A happy way to parse JSON in Dart which can avoid crush and show error detail in console. Primary purpose of this library is to find out backend error(incomplete data) at the first time.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on safe_json