• Stars
    star
    172
  • Rank 214,286 (Top 5 %)
  • Language
    Dart
  • Created over 7 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Format (JSON, XML, protobuf, mongodb, etc) and platform (server, client) agnostic serialization framework

Pub Build Status Gitter

jaguar_serializer

Format agnostic Serializer library that can be used in vm, browser and flutter for JSON, mongodb, postgresql, etc

Getting Started

Install

#pubspec.yaml
dependencies:
  jaguar_serializer: 

dev_dependencies:
  build_runner: 
  jaguar_serializer_cli: 

Simple serializer

Import jaguar_serializer

import 'package:jaguar_serializer/jaguar_serializer.dart';

Create your model.

/// User model
class User {
  String name;
  int age;
}

Declare a Serializer for your model.

@GenSerializer()
class UserJsonSerializer extends Serializer<User> with _$UserJsonSerializer {
}

Include the generated serializer functionality.

part 'user.jser.dart';

Generate Serializer

Build

Now you can build you serializer running the command

pub run build_runner build

# flutter
flutter packages pub run build_runner build

This command will generate _$UserJsonSerializer in file 'user.jser.dart'.

Use Serializer

A Serializer will serialize and deserialize between your model and Map<String, dynamic>, that can be used to apply conversion to JSON, YAML, XML, etc.

import 'package:jaguar_serializer/jaguar_serializer.dart';
import 'model/user.dart';

void main() {
  final userSerializer = new UserJsonSerializer();
  
  User user = userSerializer.fromMap({
        'name': 'John',
        'age': 25
      });
  
  print(userSerializer.toMap(user));
}

Serializer repository

You can also use a JSON repository or implement one.

import 'package:jaguar_serializer/jaguar_serializer.dart';
import 'model/user.dart';

void main() {
  final jsonRepository = new JsonRepo()..add(new UserSerializer());
  
  User user = jsonRepository.from<User>('{"name":"John","age": 25}');
  
  print(jsonRepository.serialize(user));
}

More Repositories

1

jaguar

Jaguar, a server framework built for speed, simplicity and extensible. ORM, Session, Authentication & Authorization, OAuth
Dart
457
star
2

jaguar_orm

Source-generated ORM with relations (one-to-one, one-to-many, many-to-many), preloading, cascading, polymorphic relations, etc
Dart
218
star
3

client

Contains various packages for client side
Dart
46
star
4

jaguar_flutter_asset

Serve files from Flutter assets.
Dart
25
star
5

observable_ish

Observable state and events for browser and Flutter.
Dart
24
star
6

serve

Serves static files in a directory
Dart
11
star
7

nuts

Nuts and bolts for building cross-platform UI (HTML, Flutter, CLI) using Dart. Also screw frameworks (React, Vue, Angular).
Dart
11
star
8

session

Session support for Jaguar
Dart
11
star
9

cqrs

Command Query Responsibility Separation framework for Dart
Dart
9
star
10

jaguar_hotreload

Hot reloader for Dart
Dart
9
star
11

stencil

A super simple type-safe, analyzer and code-completion friendly HTML template library for Dart
Dart
7
star
12

jaguar_validate

A simple, source generated Validator framework
Dart
5
star
13

jaguar_json

jaguar_serializer based JSON interceptors for Jaguar
Dart
4
star
14

jaguar_serializer_protobuf

Google Protocol buffer support for Jaguar serializer
Dart
3
star
15

data_store

DB agnostic abstraction of CRUD over a specific model/document/table.
Dart
2
star
16

cache

Cache layer for Jaguar
Dart
2
star
17

jaguar_rpc

A simple JSON based RPC protocol
Dart
2
star
18

logger

Level logger with backends for file, http and postgres with support for log rotation
Dart
2
star
19

auth_header

Utility library to parse and manipulate HTTP Authorisation header
Dart
2
star
20

db

Database middleware and utilities for Jaguar
Dart
2
star
21

jaguar_cli

CLI for jaguar-dart
Dart
1
star
22

jaguar_serializer_mongo

Mongo serializer helpers for jaguar_serializer
Dart
1
star
23

jaguar_recaptcha

reCAPTCHA server side support Dart and Jaguar.dart
Dart
1
star
24

jaguar_facebook_client

Facebook client for Dart from Jaguar authors
Dart
1
star