FsPickler : A fast, multi-format messaging serializer for .NET
FsPickler is a serialization library that facilitates the distribution of objects across .NET processes. The implementation focuses on performance and supporting as many types as possible, where possible. It supports multiple, pluggable serialization formats such as XML, JSON and BSON; also included is a fast binary format of its own. The library is based on the functional programming concept of pickler combinators which has been adapted to accommodate the .NET type system.
PM> Install-Package FsPickler PM> Install-Package FsPickler.Json
Example
This example demonstrates a basic serialization roundtrip using the library
1: 2: 3: 4: 5: 6: 7: |
|
Why FsPickler?
The principal motivation behind creating FsPickler is the need for a library that provides efficient, correct and complete serialization of objects in the CLR and mono runtime. It is aimed at providing a foundation for efficient communication across homogeneous .NET clusters.
FsPickler is ideally suited for serializing:
- Large and complex object graphs, such as dictionaries, trees and cyclic graphs.
- Abstract classes, subtypes, delegates and closures.
- ISerializable, DataContract or attribute-based serialization.
- F# unions, records and quotations.
- Inaccessible types or types unknown at compile time.
FsPickler is NOT:
- a general-purpose XML/JSON/BSON framework.
- a library designed for cross-platform communication.
- a library designed with version tolerance in mind. Avoid using for long-term persistence.
Documentation & Technical Overview
A collection of tutorials, technical overviews and API references of the library.
Tutorial A short introduction to FsPickler.
Technical Overview A walkthrough of the library's implementation details.
-
OUTDATED Performance Benchmarks comparing FsPickler to other established serialization libraries.
-
API Reference contains automatically generated documentation for all types, modules and functions in the library.
Who uses FsPickler?
-
MBrace framework - MBrace is a framework for distributed computation in the cloud. Its programming model uses continuations, so a library that supports serialization of closures was essential. FsPickler was designed out of this requirement.
-
Akka.NET - Used in the Akka.FSharp library for its quotation serialization capabilities.
-
Suave.IO - "we needed a simple way of serialising CLR types to put in cookies. After fighting .Net's JSONDataContractSerializer for a good while we tried FsPickler. It was a straight success; it just worked".
-
Tachyus - "FsPickler serializes and deserializes objects of virtually any type quickly and reliably in a single line of F# code. For us this makes communications between applications across computing environments effortless. There are no implementation details to obsess about".
Contributing and copyright
The project is hosted on GitHub where you can report issues, fork the project and submit pull requests.
The library is available under the MIT License. For more information see the License file in the GitHub repository.
private new : unit -> FsPickler
static member Clone : value:'T * ?pickler:Pickler<'T> * ?streamingContext:StreamingContext -> 'T
static member ComputeHash : value:'T * ?hashFactory:IHashStreamFactory -> HashResult
static member ComputeSize : value:'T * ?pickler:Pickler<'T> -> int64
static member CreateBinarySerializer : ?forceLittleEndian:bool * ?typeConverter:ITypeNameConverter * ?picklerResolver:IPicklerResolver -> BinarySerializer
static member CreateObjectSizeCounter : ?encoding:Encoding * ?resetInterval:int64 -> ObjectSizeCounter
static member CreateXmlSerializer : ?typeConverter:ITypeNameConverter * ?indent:bool * ?picklerResolver:IPicklerResolver -> XmlSerializer
static member EnsureSerializable : graph:'T * ?failOnCloneableOnlyTypes:bool -> unit
static member GatherObjectsInGraph : graph:obj -> obj []
static member GatherTypesInObjectGraph : graph:obj -> Type []
...
val int : value:'T -> int (requires member op_Explicit)
--------------------
type int = int32
--------------------
type int<'Measure> = int