remap 1.1.0

Remap #

Map-based readers and writers for json and formurlencoded serialization and deserialization.

API docs

Examples #

Use JsonReader and JsonWriter for json serialization and deserialization:

import 'package:remap/remap.dart';

void main() {
  final json = {
    'firstName': 'John',
    'lastName': 'Doe',
    'age': 20,
    'dateOfBirth': '1985-10-15'
  };

  final reader = new JsonReader.fromJson(json);
  final firstName = reader.readString('firstName');
  final lastName = reader.readString('lastName');
  final age = reader.readInt('age');
  final date = reader.readStringWith('dateOfBirth', (String s) => DateTime.parse(s));

  final writer = new JsonWriter();
  writer.writeString('firstName', firstName);
  writer.writeString('lastName', lastName);
  writer.writeInt('age', age);
  writer.writeStringWith('dateOfBirth', date, (DateTime s) => s.toIso8601String());

  print(writer.toJson());
  print(writer.toJsonString());
}

Use FormUrlEncodedReader and FormUrlEncodedWriter for formurlencoded serialization and deserialization:

import 'package:remap/remap.dart';

void main() {
  final data = 'firstName=John&lastName=Doe&age=20&dateOfBirth=1985-10-15';

  final reader = new FormUrlEncodedReader.fromFormUrlEncodedString(data);
  final firstName = reader.readString('firstName');
  final lastName = reader.readString('lastName');
  final age = reader.readInt('age');
  final date = reader.readStringWith('dateOfBirth', (String s) => DateTime.parse(s));

  final writer = new FormUrlEncodedWriter();
  writer.writeString('firstName', firstName);
  writer.writeString('lastName', lastName);
  writer.writeInt('age', age);
  writer.writeStringWith('dateOfBirth', date, (DateTime s) => s.toIso8601String());

  print(writer.toFormUrlEncoded());
  print(writer.toFormUrlEncodedString());
}

Changelog #

1.1.0 #

  • Add example

1.0.0 #

  • Initial release

example/main.dart

import 'package:remap/remap.dart';

void main() {
  final json = {
    'firstName': 'John',
    'lastName': 'Doe',
    'age': 20,
    'dateOfBirth': '1985-10-15'
  };

  final reader = new JsonReader.fromJson(json);
  final firstName = reader.readString('firstName');
  final lastName = reader.readString('lastName');
  final age = reader.readInt('age');
  final date = reader.readStringWith('dateOfBirth', (String s) => DateTime.parse(s));

  final writer = new JsonWriter();
  writer.writeString('firstName', firstName);
  writer.writeString('lastName', lastName);
  writer.writeInt('age', age);
  writer.writeStringWith('dateOfBirth', date, (DateTime s) => s.toIso8601String());

  print(writer.toJson());
  print(writer.toJsonString());
}

Use this package as a library

1. Depend on it

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


dependencies:
  remap: ^1.1.0

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:remap/remap.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
43
Health:
Code health derived from static analysis. [more]
94
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
46
Overall:
Weighted score of the above. [more]
59
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.5

Health issues and suggestions

Document public APIs. (-1 points)

103 out of 103 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/form/form_url_encoded_reader.dart. (-2.48 points)

Analysis of lib/src/form/form_url_encoded_reader.dart reported 5 hints:

line 11 col 12: Unnecessary new keyword.

line 15 col 12: Unnecessary new keyword.

line 19 col 17: Unnecessary new keyword.

line 20 col 12: Unnecessary new keyword.

line 166 col 17: Unnecessary new keyword.

Fix lib/src/form/form_url_encoded_writer.dart. (-2.48 points)

Analysis of lib/src/form/form_url_encoded_writer.dart reported 5 hints:

line 11 col 12: Unnecessary new keyword.

line 15 col 12: Unnecessary new keyword.

line 19 col 17: Unnecessary new keyword.

line 20 col 12: Unnecessary new keyword.

line 144 col 17: Unnecessary new keyword.

Format lib/src/json/json_reader.dart.

Run dartfmt to format lib/src/json/json_reader.dart.

Format lib/src/json/json_writer.dart.

Run dartfmt to format lib/src/json/json_writer.dart.

Maintenance issues and suggestions

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field https://github.com/ranquild/remap was unreachable.

Package is getting outdated. (-34.25 points)

The package was last published 70 weeks ago.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0