simple_json_mapper 2.2.0 copy "simple_json_mapper: ^2.2.0" to clipboard
simple_json_mapper: ^2.2.0 copied to clipboard

Classes and helper functions that support JSON code generation and serialization via the `simple_json` package.

example/lib/main.dart

import 'package:simple_json_mapper/simple_json_mapper.dart';

void main() {
  // The registration is normally done automatically by the generator (simple_json package)
  JsonMapper.register(JsonObjectMapper<Test>(
    (mapper, map) => Test(
      name: map['name'] as String,
    ),
    (mapper, instance) => {
      'name': instance.name,
    },
  ));

  final jsonStr = JsonMapper.serialize(Test(name: 'Blah'));
  print('Serialized JSON:');
  print(jsonStr);
  print('\nDeserialized and re-serialized JSON:');
  final obj = JsonMapper.deserialize<Test>(jsonStr);
  print(obj != null ? JsonMapper.serialize(obj) : obj);
}

@JsonObject()
class Test {
  const Test({required this.name});
  final String name;
}
5
likes
130
pub points
49%
popularity

Publisher

unverified uploader

Classes and helper functions that support JSON code generation and serialization via the `simple_json` package.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

More

Packages that depend on simple_json_mapper