safe_json 1.0.4 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.
import 'models/user.dart';
void main() {
Map<String, dynamic> json = {
'age': '30.0',
'articles': [
'article1',
'article2',
],
'vehicles': [
{'make': 'Toyota', 'model': 'Camry'},
{'make': 'Honda', 'model': 'Accord'},
],
};
User user = User.fromJson(json);
print(user.name); // John
print(user.age); // 30
print(user.school); // MIT
print(user.articles); // [article1, article2]
print(user.vehicles); // [Toyota Camry, Honda Accord]
}