transit_dart 0.8.71
transit_dart: ^0.8.71 copied to clipboard
This library provides support for marshalling Transit data to/from Dart.
transit-dart #
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.
Releases and Dependency Information #
- Latest release: 0.8.71 -- still in alpha, API is not fixed
Getting started #
Coming soon: Any Dart-specific installation things to mention here?
Usage #
WARNING: This is a terrible example, even though it works, because you have to cobble together the pieces by hand. In future we'll have a more friendly API with examples showing how to convert directly to JSON or write to a stream.
import 'package:transit_dart/transit-dart';
var handlers = WriteHandlersMap.json();
void main() {
var emitter = JsonEmitter(handlers, CacheEncoder());
print(emitter.emit("hello"));
}
Default Type Mapping #
Coming soon: Provide table of transit semantic types mapped to Dart language objects.
Testing #
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 all this can take place. The
transit-format
library andtransit-dart
library need to be side-by-side under the same parent directory. For example, createtransit-test
and inside clone transit-format.
mkdir transit-test
cd transit-test
git clone https://github.com/cognitect/transit-format.git
# Do something similar to the following to ensure Java 8.
jenv local 1.8
- Tell
transit-format
that the dart version is supported. In filesrc/transit/verify.clj
, near line 350, make this change:
;; in file `transit-format/src/transit/verify.clj`
(def supported-impls #{"transit-clj"
"transit-cljs"
"transit-dart" ;<-- insert this line
"transit-java"
"transit-jruby"
"transit-js"
"transit-python"
"transit-ruby"})
- Copy
get-transit-dart
fromtransit-dart/bin
intotransit-format/bin
.
curl "https://raw.githubusercontent.com/wevre/transit-dart/master/bin/get-transit-dart" > transit-format/bin/get-transit-dart
chmod +x transit-format/bin/get-transit-dart
- Execute the verify command. The
verify
command will check for and, as necessary, clonetransit-dart
, rundart pub get
, and compileroundtrip.dart
.
transit-format/bin/verify -impls dart
Additional information #
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 and License #
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.