simple_json_mapper 1.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • new74

simple_json_mapper #

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

1.0.2 - 07/02/2020 #

  • Handle null values on both serialization and de-serialization.

1.0.1 - 07/01/2020 #

  • Update the serialize method API by removing the generic type parameter from JsonMapper.

1.0.0 - 07/01/2020 #

  • Update the serialize method API by removing the generic type parameter. The runtimeType is used to match the correct mapper.

0.4.0 - 07/01/2020 #

  • Support serializing and deserializing of lists. deserializeList<T> method was removed. Use the normal deserialize<T> (where T is a type of List<Type>) method instead.

0.3.0 - 07/01/2020 #

  • Support serializing and deserializing of lists. Deserializing requires the actual item type so a new deserializeList<T> method was added.
  • Cleanup of API and internal usages.

0.2.2 - 06/24/2020 #

  • Keep version in sync with simple_json.

0.2.1 - 06/24/2020 #

  • Update README.

0.2.0 - 06/24/2020 #

  • Add support for custom json mapper and converters.

0.1.6 - 06/15/2020 #

  • Fix unintentionally hidden annotations.

0.1.5 - 06/15/2020 #

  • Add enum annotations. JsonEnumProperty (with alias JEnumProp) and EnumValue.

0.1.4 - 06/15/2020 #

  • Fix bug JObj const constructor.

0.1.3 - 06/15/2020 #

  • Fix bug with not revealing the new annotations.

0.1.2 - 06/15/2020 #

  • Add JObj as an alias to JsonObject and JsonProperty (with JProp alias) for controlling class property options.

0.1.1 - 06/15/2020 #

  • Add example project.

0.1.0 - 06/15/2020 #

  • Initial release.

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:');
  print(JsonMapper.serialize(JsonMapper.deserialize<Test>(jsonStr)));
}

@JsonObject()
class Test {
  const Test({this.name});
  final String name;
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  simple_json_mapper: ^1.0.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:simple_json_mapper/simple_json_mapper.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
49
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
74
Learn more about scoring.

We analyzed this package on Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13

Health issues and suggestions

Document public APIs. (-0.55 points)

65 out of 66 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/src/json_mapper.dart. (-1.49 points)

Analysis of lib/src/json_mapper.dart reported 3 hints:

line 48 col 7: DO use curly braces for all flow control structures.

line 148 col 29: The declaration '_getTypeMap' isn't referenced.

line 163 col 10: The declaration '_getTypeName' isn't referenced.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0