https://github.com/kekland/mirror_json
A JSON parser library for Dart that uses dart:mirrors.
https://github.com/kekland/mirror_json
dart dartlang json
Last synced: about 2 months ago
JSON representation
A JSON parser library for Dart that uses dart:mirrors.
- Host: GitHub
- URL: https://github.com/kekland/mirror_json
- Owner: kekland
- License: bsd-3-clause
- Created: 2019-03-28T15:17:53.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-31T07:32:55.000Z (over 6 years ago)
- Last Synced: 2023-08-20T22:33:19.470Z (about 2 years ago)
- Topics: dart, dartlang, json
- Language: Dart
- Homepage:
- Size: 6.11 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# ✨ mirror_json
[](https://github.com/kekland/mirror_json)
[](https://github.com/kekland/mirror_json/fork)

A **Dart** library for parsing JSON objects using `dart:mirrors`.
**Important: This library does not work in Flutter.**
## 🔨 Installation
Add [`mirror_json`](https://pub.dartlang.org/packages/mirror_json) to your dependencies.
```yaml
dependencies:
...
mirror_json:
```Now get the packages.
```bash
pub get
```## 🔮 Getting started
`mirror_json` uses a concept of *Parsers*. There are a bunch of parsers for simple types (int, double, String) already in the package, but in order to parse a class, you have to make a `ClassParser` instance.
```dart
import 'package:mirror_json/mirror_json.dart';@JsonParseable()
class MyClass {
...
}void main() {
GlobalJsonParserInstance.initialize();
var parser = ClassParser();// From json
var myObject = Json.fromJson({...});// To json
var json = Json.toJson(myObject);
}
```Woah, what just happened?
First, we initialized `mirror_json`'s main class, `GlobalJsonParserInstance`. This automatically adds parsers for simple types like int, double, List, etc. Then, we created a parser for `MyClass`. Now you can use the `Json` class to transform your JSON objects to `MyClass` instances or `MyClass` objects to JSON.
## 💡 Example
See example under `example` folder.
## 📚 Docs
See docs [**here**](https://kekland.github.io/mirror_json)
## 📭 Contact me
E-Mail: **kk.erzhan@gmail.com**