Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jacob-carlborg/orange
A serialization library for the D programming language.
https://github.com/jacob-carlborg/orange
Last synced: about 2 hours ago
JSON representation
A serialization library for the D programming language.
- Host: GitHub
- URL: https://github.com/jacob-carlborg/orange
- Owner: jacob-carlborg
- Created: 2011-08-16T18:03:15.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2020-03-21T19:06:05.000Z (over 4 years ago)
- Last Synced: 2024-08-04T01:03:51.831Z (4 months ago)
- Language: D
- Homepage:
- Size: 892 KB
- Stars: 71
- Watchers: 7
- Forks: 15
- Open Issues: 19
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
- awesome-d - orange - General purpose serializer (currently only supports XML) (Data serialization / XML)
README
# Orange [![Build Status](https://travis-ci.org/jacob-carlborg/orange.svg?branch=master)](https://travis-ci.org/jacob-carlborg/orange) [![Go to orange](https://img.shields.io/dub/v/orange.svg)](https://code.dlang.org/packages/orange)
Orange is a serialization library for the D programming language. It supports D1/Tango and D2/Phobos.
It can serialize most of the available types in D, including third party types and can serialize
through base class references. It supports fully automatic serialization of all supported types
and also supports several ways to customize the serialization process. Orange has a separate front end
(the serializer) and back end (the archive) making it possible for the user to create new archive
types that can be used with the existing serializer.## Building
### Requirements
* Dub http://code.dlang.org/download
### Building
1. Install all requirements
1. Clone the repository
1. Run `dub build`## Unit Tests
Run the unit tests using Dub `dub test`
## Simple Usage Example
```d
module main;import orange.serialization._;
import orange.serialization.archives._;class Foo
{
int a;
}void main ()
{
auto foo = new Foo; // create something to serialize
foo.a = 3; // change the default value of "a"auto archive = new XmlArchive!(char); // create an XML archive
auto serializer = new Serializer(archive); // create the serializerserializer.serialize(foo); // serialize "foo"
// deserialize the serialized data as an instance of "Foo"
auto f = serializer.deserialize!(Foo)(archive.untypedData);// verify that the deserialized value is equal to the original value
assert(f.a == foo.a);
}
```### More Examples
See the [test](https://github.com/jacob-carlborg/orange/tree/master/tests)
directory for some examples.## D Versions
* D2/Phobos - master branch
* D2/Tango - See the [mambo repository](https://github.com/jacob-carlborg/mambo).
The API is the same, just replace "orange" with "mambo" for the imports
* D1/Tango - d1 branch
* D1/Tango and D2/Phobos in the same branch - mix branch