json_to_dart 1.0.4

JSON to Dart #

Build Status

Given a JSON string, this library will generate all the necessary Dart classes to parse and generate JSON.

This library is designed to generate Flutter friendly model classes following the flutter's doc recommendation.

Caveats #

  • When an empty array is given, it will create a List
  • Equal structures are not detected yet (Equal classes are going to be created over and over).
  • Properties named with funky names (like "!breaks", "|breaks", etc) or keyword (like "this", "break", "class", etc) will produce syntax errors.
  • Array of arrays are not supported:
[[{ "isThisSupported": false }]]
[{ "thisSupported": [{ "cool": true }] }]

Use this package as a library

1. Depend on it

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

  json_to_dart: ^1.0.4

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

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

  • Dart: 2.7.0
  • pana: 0.13.4

Health issues and suggestions

Document public APIs. (-0.08 points)

92 out of 95 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/syntax.dart. (-7.24 points)

Analysis of lib/syntax.dart reported 15 hints, including:

line 16 col 10: Unnecessary new keyword.

line 20 col 10: Unnecessary new keyword.

line 24 col 10: Unnecessary new keyword.

line 46 col 11: Use isNotEmpty instead of length

line 58 col 14: Unnecessary new keyword.

Fix lib/helpers.dart. (-5.84 points)

Analysis of lib/helpers.dart reported 12 hints, including:

line 1 col 26: Use lowercase_with_underscores when specifying a library prefix.

line 7 col 43: Avoid const keyword.

line 56 col 28: Unnecessary new keyword.

line 72 col 28: Unnecessary new keyword.

line 97 col 15: Use isNotEmpty instead of length

Fix lib/model_generator.dart. (-4.89 points)

Analysis of lib/model_generator.dart reported 10 hints, including:

line 25 col 38: Unnecessary new keyword.

line 26 col 48: Unnecessary new keyword.

line 33 col 20: Unnecessary new keyword.

line 43 col 30: Unnecessary new keyword.

line 52 col 11: Unnecessary new keyword.

Maintenance issues and suggestions

Provide a file named CHANGELOG.md. (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and json_to_dart.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
convert ^2.0.1 2.1.1
dart_style ^1.0.10 1.3.3
json_ast ^1.0.5 1.0.5
Transitive dependencies
_fe_analyzer_shared 1.0.3
analyzer 0.39.4
args 1.5.2
async 2.4.0
charcode 1.1.2
collection 1.14.12
crypto 2.1.4
csslib 0.16.1
glob 1.2.0
grapheme_splitter 1.0.0
html 0.14.0+3
js 0.6.1+1
meta 1.1.8
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.1.0
pedantic 1.9.0
pub_semver 1.4.2
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
watcher 0.9.7+13
yaml 2.2.0
Dev dependencies
path ^1.6.4 1.6.4
test ^1.9.4