json_class
peiffer-innovations/json_class open-source repository details.
Ver no GitHub ↗Arquivado
- Estrelas
- 2
- Forks
- 5
- Último push (UTC)
- 16 de fev. de 2026
- Status do projeto
- Arquivado
README original
Texto original em inglês. Visite o GitHub para a versão atual.
Table of Contents
json_class
Singular class that when extended can encode itself to a JSON compatible map or list. This also provides convenience functions to decode from a JSON compatible map or list to the actual data model.
Using the library
Add the repo to your Flutter pubspec.yaml file.
dependencies:
json_class: <<version>>
Then run...
flutter packages get
Example
import 'package:json_class/json_class.dart';
import 'package:meta/meta.dart';
@immutable
class Person extends JsonClass {
Person({
this.age,
this.minor,
this.firstName,
this.lastName,
});
final int age;
final bool minor;
final String firstName;
final String lastName;
static Person fromDynamic(dynamic map) {
// It's recommended to use dynamic over Map<String, dynamic> because it's
// compatible with other types of map-like results such as Firebase Realtime
// Database's values or the ones returned from sqlflite.
Person result;
if (map != null) {
result = Person(
age: JsonClass.parseInt(map['age']),
minor: JsonClass.parseBool(map['minor']),
firstName: map['firstName'],
lastName: map['lastName'],
);
}
return result;
}
static List<Person> fromDynamicList(Iterable<dynamic> list) {
List<Person> results;
if (list != null) {
results = [];
for (dynamic map in list) {
results.add(fromDynamic(map));
}
}
return results;
}
@override
Map<String, dynamic> toJson() => JsonClass.removeNull({
age: age,
minor: minor,
firstName: firstName,
lastName: lastName,
});
}
LinguagensDart
Dependências usadas
Lista de dependências 5 itens
- intl
>=0.18.0<1.0.0 - logging
^1.2.0 - meta
^1.12.0 - flutter_lintsDesenvolvimento
^5.0.0 - testDesenvolvimento
^1.25.8
Como escolher um repositório para seu projeto?
Filtre pelo caso de uso, compare a atividade e confira o projeto original antes de adotá-lo.
- Busque por nome, autor ou descrição e filtre por tema.
- Compare estrelas, forks e envios recentes. Estrelas indicam interesse, mas não garantem qualidade.
- Confira o README, a licença e as issues no GitHub antes de usar o projeto.
Fontes e manutenção
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗