p-hatan/ mirror

pub repository

mirror.p-hatan.ir

serialization

0.10.2

Provide a serialization facility for Dart objects.

Download archive

Readme

General serialization for Dart objects.

Build Status

Save and restore objects flexibly.

This can serialize and de-serialize objects to multiple different formats. It is most useful if you have Dart on both ends, rather than needing to communicate with an external system. It can handle cycles, inheritance, getters and setters, private or final fields set via constructors, objects serialized in different ways at different times, and other complex options. It can handle serializing acyclic objects with only public fields to a simple JSON format, but might be more heavyweight than is necessary if that's the only requirement.

This has no privileged access to object representations, so objects are accessed and created according to their public APIs. As a result, serializations from older versions where the internal representation has changed can still be read as long as the public API is still available.

The way an object's state is read and written is defined by SerializationRules. These can be implemented in various ways. The easiest to use is using mirrors to find the members. Rules can also be hand-written or, for relatively simple classes, generated using a transformer.

Usage

Import either

import "package:serialization/serialization.dart"

or

import "package:serialization/serialization_mirrors.dart"

depending on whether or not you want the mirrored rules. These are more convenient, but cause increased code size in dartj2s.

To use the transformer, include something in your pubspec like

 transformers:
   - serialization :
     $include: ["lib/stuff.dart", "lib/more_stuff.dart"]

and set up the generated rules in a Serialization instance, on which you can then call write().

import 'package:my_package/stuff_serialization_rules.dart' as foo;
 ...
 var serialization = new Serialization();
 foo.rules.values.forEach(serialization.addRule);
 ...
 sendToClient(serialization.write(somePerson));

and on the client, do something like

 p = readFromServer(personId).then((data) => serialization.read(data));

If you're using the mirrored rules, then you can just tell the serialization which classes you're interested in.

  var serialization = new Serialization()
    ..addRuleFor(Address);
  serialization.write(address);

Requests and bugs

Please file feature requests and bugs via the GitHub Issue Tracker. This is licensed under the same license as Dart

Disclaimer

This is not an official Google project.

Changelog

0.10.2

  • Update README

  • Fixes for transformer when generating maps, test that option properly.

0.10.1

  • Adds a transformer that can generate serialization rules for simple classes.

0.10.0

  • BREAKING CHANGE: serialization.dart no longer imports dart:mirrors by default. If you want mirrors, import serialization_mirrors.dart instead. Note that the default ordering of rules has also changed, because the non-mirrored version no longer includes SymbolRule, so even in the mirrored version it occurs later in the order. So even if you are still using mirrors, data serialized using an older version with default rule setup may not deserialize in this version. If you need to do this, you can explicitly create a Serialization instance with the old numbering.

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add serialization
pubspec.yaml
name: serialization
version: 0.10.2
author: Alan Knight <alanknight@google.com>
description: Provide a serialization facility for Dart objects.
homepage: https://github.com/google/serialization.dart
environment:
  sdk: '>=1.0.0 <2.0.0'
dependencies:
  analyzer: '>=0.21.1 <0.24.0'
  barback: '>=0.13.0 <0.16.0'
dev_dependencies:
  unittest: '>=0.9.0 <0.12.0'
transformers:
  - serialization :
      $include: ["test/transformer/test_models.dart"]
  - serialization : 
      $include: ["test/transformer/test_models_for_maps.dart"]
      format: "maps"

Version history

VersionPublishedArchiveSHA-256
0.2.8+22012-12-11T21:42:48.188790ZDownloadc63329f90415db49ca2998467f893c4e1faea6558f25fdd22d2f3369de890418
0.2.10+12013-01-14T19:11:06.143590ZDownload2910f1fc846d50db9ade2894560abb605ec49bfd73c088c6b0e20b325ddf03af
0.3.1+12013-01-22T22:02:54.354680ZDownload7eb41599acfbf5aa4ebc643556a8787cceee833d39e3f83c1b16c898d1a54921
0.3.22013-01-28T20:40:05.967560ZDownload38d6ad89e3212933342e4e60bb181f29fa1cbfd88e5032a84cc4b0625d4cd0e9
0.3.42013-02-05T17:00:05.292260ZDownloadde17ed3b79c1f10b65fac690d2358784af2a4db26721c174ac1feec96c81d038
0.3.5+12013-02-11T19:57:51.137060ZDownloada37ca65f0e30cae82335b130e30657d4fa5fbfe410e449a2e053f3faca8afa80
0.3.7+62013-02-20T20:46:08.381570ZDownloada15efae894848e276f1cee87d1da47240aef085338159a10dfba34e080393dfd
0.4.02013-02-25T18:40:46.854930ZDownload7320f52af3fed5d80e854b30ce42befce75e9d37d57c39da6f69a261bbd95b4c
0.4.12013-03-05T19:05:50.205280ZDownloadeb74e33504c3a0cf1514fc7d5b5494ab07df2145771b621f679f70176949b29b
0.4.22013-03-16T00:13:58.768820ZDownload5dfc9ff980564ae8158bedbaa6c8dfb48483b53b17cd5090e70573b3d8ead827
0.4.3+12013-03-25T19:53:20.933730ZDownload67394c457d6422ab35cc1eaab7fc58c172f15c996d59f4aae2f68246afec0b62
0.4.4+42013-04-03T17:57:19.876940ZDownload02c3faadb1531fd48ed766ee2ee9d88ee6d9bd9a37da40f2ce0845a40acd25a4
0.4.5+12013-04-08T23:14:05.675430ZDownload587b9ac431c258119e79b94ef7676e37b9f2515903cfc03b74bfedc60cfb5ee5
0.4.7+12013-04-16T15:42:33.842510ZDownloada9f0e22a4a2080e10cb9541322d60bacdc0a66b937dec9b8cd261b4a800a3f05
0.5.0+12013-04-23T00:51:09.430ZDownload3a0132ac20c0e0546a2908e00cb5957ef16b83ef7e9809e29ebb596f7b0b16b8
0.5.0+22013-04-25T23:36:33.672860ZDownload504824ab29188637d6f82dc24d680f45cb1c94310479f7833cbd77a107638b30
0.5.12013-04-29T18:52:37.657360ZDownloadd98ef961b1a0eb82cc72fd2097305b8d9399dc1349935f2e2a28ba25ffdbc979
0.5.42013-05-03T16:42:34.891170ZDownload5b4bdbc125201a2e9d6103c9686c4b77e76fa9454ba9d1deeb81ea0a99ab8233
0.5.52013-05-06T19:19:20.341550ZDownload155f618574b5c402ff6bc291da70377fa1d5a8c03f576e5061dad8840f61df24
0.5.62013-05-08T16:44:46.844600ZDownload0f03af0999d4eb82952810a615b4cbb647c68997972ba12c66460547adf06c76
0.5.72013-05-10T05:06:14.597590ZDownloadb5609efddcd3350a92fae7fc2581e1edd84c59f9b33d9aeb101977453aabbf81
0.5.92013-05-20T15:45:05.141920ZDownload0df9076eb9800c89b3c872dd415d770cdac9bbb42ab9d2babb979321672c2043
0.5.11+12013-05-29T00:09:36.544240ZDownloadb4993c74cea757796e7b054b77a684fea00acb704bd3764762fd39b6227c8294
0.5.122013-05-29T18:31:43.473950ZDownload2aa6c84760345ebc73568d9be39788b8f8e5869ba1d4190283b1a4a44aba83b2
0.5.132013-06-03T16:05:17.985460ZDownload43cbb78b80f03e99efebdc75ab4c0d58d148a8bc8247bf40899dee8aec4038e3
0.5.14+12013-06-05T15:05:15.258340ZDownload0702000359ab9acc7d186bb57578154fa10692e6d4f8a6bf56e4dfbbb507669f
0.5.14+32013-06-06T16:37:13.726360ZDownload30aecb8f0531015f1a585baef51b1e69adfe35cd07fff31291541f86cdda4e35
0.5.152013-06-07T23:01:39.983540ZDownload0535eee74df1a433c39ae45fe49c1bf142b4859758ac13056bbcf9929126c025
0.5.162013-06-10T16:38:31.798170ZDownloadf22fe4b1d4833876cff8e3477c0161cfcfa4b48d9c68323a2a59c14cf51bea72
0.5.172013-06-12T17:53:28.894420ZDownload23da53331fcae2e639f1d71b56a724d2b133da9bcf4afb652844a675a3e69960
0.5.202013-06-17T22:08:40.655150ZDownload0263a028f403fab576f5928c3ed571445ac7f8b93ff327db7dec87a7b8e3dec2
0.6.12013-06-27T19:32:09.216830ZDownload40b37f8c9b144d6020343b3e34b741ff53cbff107679c05ccc9af2bccb2fe682
0.6.22013-06-28T20:55:54.463240ZDownload10bfd8faaf868c995292a7a04c8a50dfa7513fcab5894307401bd66d0bbbfd1e
0.6.3+12013-07-09T00:23:54.562950ZDownloada9987d25669c9f622651df1ca9626206ff652c3a5a4a83d531becc25eef294be
0.6.52013-07-16T00:19:12.876150ZDownload9f892b7a121c157d7cd907667b3ed58990d2c0ea7f9b7a648337c0c3117041a3
0.6.62013-07-17T19:40:31.924910ZDownloada116bcba3f40ec6d8fe63b0f1e4997aff5c58f1e1723d5956f8e22bc3111714b
0.6.82013-07-19T20:55:22.128250ZDownload4b7a6d542433d50b22229a3a5ee973db1c2e847e4b2d7a327fc77b91ad7bdde6
0.6.92013-07-22T15:13:31.941500ZDownload47ca2c5028f1af3eaf48018f61724fb65190a9a2701173f89ae9ebb5978f98a0
0.6.9+22013-07-24T03:58:27.076850ZDownload7ddd67f19bd452e2f958a42e0e15494db052f69c654cd648a3227129db817ee8
0.6.112013-07-25T05:09:36.262660ZDownload3d23bc5040ab94854e1bac8d8f0a47216b3bc12e5061b42033ce9e4179764f52
0.6.122013-07-26T20:05:54.441840ZDownload471d9cca301cb47815d07b5a8429195ad8a5d9363e87651133ec7133dba5e240
0.6.132013-07-30T21:55:40.621820ZDownload10b4d2d045cc4adb9ca70dc14c5be793f45238ad7479bd506185228ba9989778
0.6.142013-08-02T16:24:25.405770ZDownloadc6f51c8da1d3450f07cde006ee9238d978cf9874cbf8d831742e954b069f8d10
0.6.15+22013-08-05T22:49:28.153200ZDownload75b097ee876f26cc77eb2f603887d1d66eac74a3e6b61bc581a61ec600a2a9a6
0.6.15+32013-08-06T20:12:51.880680ZDownload13797d93d032ebb5cd64d9e41599efc01bb463732b4fc97308e47b2d1c626b0f
0.6.172013-08-10T17:35:15.713490ZDownload36c0008a7338aa4b0777b199b189a3513255dfb9c48e95934f5a5552fa092689
0.6.17+22013-08-12T22:21:20.670940ZDownload363147dd88d649ca85c73b357e2626f6ea1dec00ce9c7d85981f082c06cd032c
0.6.192013-08-19T16:10:38.017580ZDownloadc7e5ad21e56d1f47b803480a13b6723ce918451a5efa07032e20b992040ad85b
0.6.20+12013-08-22T18:19:02.047660ZDownload469519b1c639d3f9acb1611eae0c8c7a8c60bf818ef08de0386880b9977516a3
0.6.21+32013-08-26T17:42:19.539500ZDownload6479fa0b933223e2c5e34cfed2561fed091f49797178a324fc3b93452711c485
0.7.02013-08-28T19:28:48.394280ZDownload58c66475680516332a5850bce1d1f4118eadfc74077ce7921d803a4d1cba130c
0.7.12013-09-03T15:50:00.625130ZDownload75fa8b2de274c9203287af81f636b04fa3ffa24deed7273afecc32897bcf98d1
0.7.22013-09-06T15:50:46.978190ZDownload25d14cf99cb5ef083231bd3f8204b435462cf6d702656ccc8d9e6dba618087b9
0.7.2+12013-09-08T15:46:10.903590ZDownload3635a5703bf3452f0de718a62a9fbd05e749e5e9f3250401f2fd6aaac2ff32e0
0.7.3+12013-09-16T15:43:11.893720ZDownloade60811a6f077cd75cfd630e4a9a72b55f953cdd6d28eb9ee360ddbb472f29eb0
0.7.42013-09-18T03:03:25.186190ZDownload85d2edf447601e7fac9e5ebcbdbac046f1160efc5023afc8e1c2ea38415b7259
0.7.52013-09-20T23:25:28.164290ZDownloadeed6cd6ff473842c2073dd1320445e7094b28372aeeb2a5b162a03134e5c15f3
0.7.62013-09-27T14:56:15.444110ZDownload4b7ac2bf7c7e08f2fd5d633b7295982712f476683634a73e514ac8cb2b6be9eb
0.7.6+42013-10-01T23:47:47.430330ZDownloadde806ad9766a38867c2b08a228fc64b3932d694aaeb5cee6cd81e426eddddce5
0.8.02013-10-03T16:26:32.089080ZDownload519a60b7d0bdac6f3a774c361c2b98cebebb411b23cad39b81ae8b1589f143d6
0.8.12013-10-04T21:53:45.234090ZDownload61591afb6dfd7a32692a0e3c0ab36db14d997fea1ebf5873c508f8d342477a64
0.8.22013-10-14T21:41:15.386180ZDownloade0e3f9f2322be0dfc2fa526b2292c0251d21c6075fa68d648b3a3f5a0c2957c3
0.8.32013-10-17T15:59:53.207390ZDownloade45e36caacea3db7238d58c7d6e566eeac872020f5d7722c58926d77b2cbe6c9
0.8.42013-10-19T21:08:19.940960ZDownload76e51f3a48b65c19d1a39e4d6ae864cfe9ec832eb6962624e22e70484d9dbeaa
0.8.52013-10-21T15:49:59.868480ZDownload4231ae0846ec0af40938406575e7e5223037e737e5d40206aa3513404ea12c75
0.8.62013-10-24T08:18:07.807540ZDownloadc46108bb284d7b28b75566083e79b7058ab8314ccd820033bdc0b22f146218e0
0.8.72013-10-28T14:29:54.995050ZDownload2748fbe70ebf0f0a9e8eea4328c761837d97d14063003988989cee0f2c56f287
0.8.82013-10-30T03:29:07.580180ZDownload5dcde175ae9d2fe350f51c93abb7a1166c203f17da8c0a92a1d6680d99229c1b
0.8.92013-10-31T15:15:28.749140ZDownload37ec168626323f0e946c680aa09cd7c9d892322a04ff34ee00d0a343675b34b6
0.8.102013-11-01T19:22:54.007050ZDownloadff1c64f76fa29d0d7ea6af48836f367f4f8c3f1347d4772465ff4ade105652f3
0.8.10+32013-11-04T16:48:35.005270ZDownloada673d20ad7c80b47d54964c790f3047640187736aaf7f8ba59f230af6617f4b6
0.8.10+42013-11-05T16:04:24.870860ZDownloade78a929ea65c2cc385fd06a8f76ffc0e8cebb5c4f6c5ae36a2c7f4c245f5e89d
0.9.02013-11-06T19:30:57.153130ZDownloada14116f95a509f7c48736f24c09e2b615285d61cc887c2a29335e35df899a54f
0.9.12013-12-19T22:47:28.464110ZDownloadfc66bc9607b5a78dba1f6f85885d9555e7eda17e6d8170d2afae3c36ebd0a183
0.9.1+12014-07-23T17:18:18.471410ZDownloadfb42b9a8cf7c8d1fa2cd3742935b66b8f573818b615d3a6537a0f60cb10329c9
0.10.02014-09-19T21:41:45.962710ZDownloaded037bdf036edb8bbb43c950e8433ca72c388c09ef22cd3b7706385c4f6576e4
0.10.12014-10-15T23:21:10.547840ZDownloadafb9195c9d33984300bf66711b0680b659621c5522fd470f94f2f40bb35255dd
0.10.22014-10-21T18:19:24.754850ZDownload68226927ce5eb0d32ed0c9008fa740e81e6dda5f53ff651342572d09bb2de393
0.10.32014-10-31T18:31:15.878350ZDownload278b19f02bfd902a67e1047ee0d5bc2b38241ff65f7a2ab7f3686805b85061a0
0.10.42015-01-26T20:54:43.938880ZDownloadb7d94c8540bc4db167f74cda069d591a6bb87cbe1ef6cfc6e0742f73615f975d
0.10.4+22015-11-02T21:33:59.026ZDownload27795a4848c821614b6ecce64d26772006316dad85ecf8bd717999c7e8e60ae0
0.10.4+32016-01-29T22:06:18.123ZDownload42f81f8edf1da24d2838f609c650a760b92118217291e10eff6ee7f23db6e0d1
0.10.4+42016-02-03T17:55:08.175ZDownload610205a5ac194d7f0cc1e8676668331f42764deae57bc304949ba15e2a42e06d

Dependencies

analyzer "\u003e=0.21.1 \u003c0.24.0"

barback "\u003e=0.13.0 \u003c0.16.0"