safe_json 1.0.10 safe_json: ^1.0.10 copied to clipboard
Primary purpose of this library is to find out backend error(incomplete data) at the first time.
safe_json #
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;
//set the stacktrace count showing in console
SafeJsonLibrary.stackTraceCount = 1;
Console Logs #
Installation #
Add safe_json
to your pubspec.yaml
file:
dependencies:
safe_json: ^1.0.7