A Dart library for parsing JSON Feed format feeds. This package provides strongly-typed models and utilities for working with JSON Feed data, including validation and error handling.
- Fully-typed models for JSON Feed, Item, Author, Attachment, and Hub (using freezed and json_serializable)
- Simple API for parsing JSON Feed strings
- Custom exception handling for invalid feeds
- Null safety and modern Dart support
Add this package to your pubspec.yaml:
dependencies:
jsonfeed:
git:
url: https://github.com/imprologic/json_feed.gitImport and use in your Dart code:
import 'package:jsonfeed/json_feed.dart';
void main() {
final jsonString = '{ ... }'; // your JSON Feed string
try {
final feed = parseJsonFeed(jsonString);
print(feed.title);
} catch (e) {
print('Failed to parse feed: $e');
}
}This package uses code generation for immutable models. Run the following command to generate the necessary files:
dart run build_runner watch -dTo run the unit tests:
dart testlib/json_feed.dart: Main library entry point and parserlib/src/models.dart: Data models for JSON Feed and related typestest/json_feed_test.dart: Unit tests
See LICENSE.