A Dart serialization/deserialization library to convert Dart Objects into JSON and back
- One serializable class per file.
- No duplicated serializable class name.
- Do NOT pass generic type to Rson.fromJson;
- Setup a serializable class by decorating with @Serializable()
import "package:rson/rson.dart";
@Serializable()
class Entity {
int a;
}
- Serialization
void main() {
var entity = new Entity();
entity.a = 1;
print(Rson.toJson(entity)); // output: {"a":1}
}
- Deserialization
void main() {
var entity = Rson.fromJson<Entity>({"a": 1});
print(entity.a); // output: 1
}