dynatype 2.0.0 copy "dynatype: ^2.0.0" to clipboard
dynatype: ^2.0.0 copied to clipboard

The package helps developers make the process easy by validating the response of type JSON. The person using this package does not need to worry about any exception in JSON Map Entries.

example/dynatype_example.dart

import 'package:dynatype/dynatype.dart';

void main() {
  // Define a JSON string
  const String jsonString =
      '{"title": "Title 1", "author": "Author 1", "year": 2023, "tags": ["Tag 1", "Tag 2"]}';

  // Define a schema for the JSON string
  final Map<String, List<DynaType>> schema = {
    "": [
      DynaType(key: "title", type: String),
      DynaType(key: "author", type: String),
      DynaType(key: "year", type: int),
      DynaType(key: "tags", type: List<String>),
    ],
  };

  // Validate the JSON string against the schema
  try {
    DynaValidator(json: jsonString, schema: schema).validate();
    print("The JSON is valid according to the schema.");
  } catch (e) {
    print('Error: $e');
  }
}
3
likes
130
pub points
0%
popularity

Publisher

verified publisherlivnium.com

The package helps developers make the process easy by validating the response of type JSON. The person using this package does not need to worry about any exception in JSON Map Entries.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

equatable

More

Packages that depend on dynatype