Transit is a data format and set of libraries for conveying values between applications written in different languages. This library provides support for marshalling Transit data to/from Dart.
This implementation's major.minor version number corresponds to the version of the Transit specification it supports.
NOTE: Transit is intended primarily as a wire protocol for transferring data between applications. If storing Transit data durably, readers and writers are expected to use the same version of Transit and you are responsible for migrating/transforming/re-storing that data when and if the transit format changes.
- Latest release: 0.8.117
dart pub add transit_dart
Then in your Dart code, you can use:
import 'package:transit_dart/transit_dart.dart';
See Installing.
See Example
We don't support the full list of types that one would find in, say, the java or clj implemenation of transit. In spite of that limitation, everything will round trip (which is why transit-dart can pass the transit-format test suite) and any missing types can be implemented as custom read/write handlers, or by constructing a TaggedValue.
Transit Type | Write accepts | Read produces |
---|---|---|
null | null | null |
string | String | String |
boolean | bool | bool |
integer | int | int |
decimal | double | double |
bytes | Uint8List | Uint8List |
time | DateTime | DateTime |
uri | Uri | Uri |
special numbers | double.nan, double.infinity, double.negativeInfinity | double.nan, double.infinity, double.negativeInfinity |
array | List | List |
map | Map | Map |
set | Set | Set |
To run the roundtrip verification tests in transit-format
, first ensure
Dart>=2.19.1 and Java 8 are installed, then do the following:
- Set up a testing directory where
transit-format
andtransit-dart
can be cloned side-by-side. We have a fork oftransit-format
that has support for testingtransit-dart
all ready to go. Clone this to your test folder.
mkdir transit-test
cd transit-test
git clone https://github.com/wevre/transit-format.git
# Do something similar to the following to ensure Java 8.
jenv local 1.8
- From the
transit-format
folder, run the verify command.
bin/verify -impls dart
Coming soon, more info about the package: where to find more information, how to contribute to the package, how to file issues, what response they can expect from the package authors, and more.
Copyright © 2023 Michael J. Weaver
This library is a Dart port of the Java version created and maintained by Cognitect.
Copyright © 2014 Cognitect
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.