json_feed 0.1.1
json_feed: ^0.1.1 copied to clipboard
A Dart implementation of JSON Feed v1.1 with freezed/json_serializable codegen.
JsonFeed Parser for Dart #
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.
Features #
- 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
Getting Started #
Add this package to your pubspec.yaml:
dependencies:
jsonfeed:
git:
url: https://github.com/imprologic/json_feed.git
Import 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');
}
}
Code Generation #
This package uses code generation for immutable models. Run the following command to generate the necessary files:
dart run build_runner watch -d
Running Tests #
To run the unit tests:
dart test
Project Structure #
lib/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
License #
See LICENSE.