lazydata 0.1.0

Fast serializer supporting multiple formats targetting game developers

There is a newer version of this package available.
See the version list below for details.
Install-Package lazydata -Version 0.1.0
dotnet add package lazydata --version 0.1.0
<PackageReference Include="lazydata" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add lazydata --version 0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: lazydata, 0.1.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install lazydata as a Cake Addin
#addin nuget:?package=lazydata&version=0.1.0

// Install lazydata as a Cake Tool
#tool nuget:?package=lazydata&version=0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

LazyData

A quick data (de)serialization framework for varying data formats in .net with a focus on clean and minimal serialized output for each format, mainly for game development scenarios such as in Unity, MonoGame etc.

Build Status Join Gitter Chat

Formats supported

  • Json (via some JSON.Net implementation)
  • Xml
  • Binary

If you are interested in how the outputs would look take a look here

Examples

If you are SUPER lazy you can use the SuperLazy.Transformer to get stuff done like a typical serialization framework:

var modelIn = new SomeModel();
var data = Transformer.ToJson(modelIn);
var modelOut = Transformer.FromJson(data);

You can even lazily transform your data between formats on the fly, which is helpful if you debug in JSON but want to use Binary for production, here is an example of one of the tests:

var model = SerializationTestHelper.GeneratePopulatedModel();

var expectdString = Transformer.ToJson(model);
var xml = Transformer.FromJsonToXml(expectdString);
var binary = Transformer.FromXmlToBinary(xml);
var json = Transformer.FromBinaryToJson(binary);

Assert.AreEqual(expectdString, json);

Non Lazy Approach

The static transformer is there for people who dont care about customizing the library and just want to (de)serialize everything however the library was built to be configurable so you can skip the helper Transformer class and make the serializers yourself like so:

public class SomeClass
{
    public float SomeValue { get; set; }
}

var mappingRegistry = new MappingRegistry(new EverythingTypeMapper());
var serializer = new JsonSerializer(_mappingRegistry);
var output = serializer.Serialize(model);
Console.WriteLine("FileSize: " + output.AsString.Length + " bytes");
Console.WriteLine(output.AsString);

Deserialize stuff

var someDataFromAFile = getData();
var dataObject = new DataObject(someDataFromAFile);

var mappingRegistry = new MappingRegistry(new EverythingTypeMapper());
var deserializer = new JsonSerializer(_mappingRegistry);
var model = deserializer.Deserialize<TypeOfModel>(dataObject);

You can alternatively use an DefaultTypeMapper instead of the EverythingTypeMapper which will only attempt to serialize things with attributes on. The allowing you to not need any custom attributes. This is handy for scenarios where you just treat your models as pure data classes.

Only serialize certain properties

[Persist]
public class SomeClass
{
    [PersistData]
    public float SomeValue { get; set; }

    public string NotPersisted { get; set; }
}

var mappingRegistry = new MappingRegistry(new DefaultTypeMapper());
var serializer = new JsonSerializer(_mappingRegistry);
var output = serializer.Serialize(model);

Console.WriteLine("FileSize: " + output.AsString.Length + " bytes");
Console.WriteLine(output.AsString);

The [Persist] attribute indicates that this should be output in the serialized data, on a class it indicates it is a root object that contains serialized data, on a property it indicates the property should be mapped.

This attribute is used rather than [Serialize] because it is due to it being originally meant for ETL processes, if you want to just treat it like a serialization framework you can bypass the need for attributes entirely.

Docs

Check out the docs directory for docs which go into more detail.

Tests

There are a suite of unit tests which verify most scenarios, as well as output some performance related stats, it is recommended you take a peek at them if you want to see more advanced scenarios.

Blurb

This was originally part of the Persistity library for unity (which was originally part of EcsRx library), however was separated out to make more generic and reuseable and although its still meant to be used as a smaller part of a larger process, it has some helpers to allow it to be used just like a basic serializer without much effort.

The original focus of this library was to provide a consistent way to pass data around and convert/transform it between formats and types easily however as the serialization pieces can be used in isolation purely for serialization

LazyData

A quick data (de)serialization framework for varying data formats in .net with a focus on clean and minimal serialized output for each format, mainly for game development scenarios such as in Unity, MonoGame etc.

Build Status Join Gitter Chat

Formats supported

  • Json (via some JSON.Net implementation)
  • Xml
  • Binary

If you are interested in how the outputs would look take a look here

Examples

If you are SUPER lazy you can use the SuperLazy.Transformer to get stuff done like a typical serialization framework:

var modelIn = new SomeModel();
var data = Transformer.ToJson(modelIn);
var modelOut = Transformer.FromJson(data);

You can even lazily transform your data between formats on the fly, which is helpful if you debug in JSON but want to use Binary for production, here is an example of one of the tests:

var model = SerializationTestHelper.GeneratePopulatedModel();

var expectdString = Transformer.ToJson(model);
var xml = Transformer.FromJsonToXml(expectdString);
var binary = Transformer.FromXmlToBinary(xml);
var json = Transformer.FromBinaryToJson(binary);

Assert.AreEqual(expectdString, json);

Non Lazy Approach

The static transformer is there for people who dont care about customizing the library and just want to (de)serialize everything however the library was built to be configurable so you can skip the helper Transformer class and make the serializers yourself like so:

public class SomeClass
{
    public float SomeValue { get; set; }
}

var mappingRegistry = new MappingRegistry(new EverythingTypeMapper());
var serializer = new JsonSerializer(_mappingRegistry);
var output = serializer.Serialize(model);
Console.WriteLine("FileSize: " + output.AsString.Length + " bytes");
Console.WriteLine(output.AsString);

Deserialize stuff

var someDataFromAFile = getData();
var dataObject = new DataObject(someDataFromAFile);

var mappingRegistry = new MappingRegistry(new EverythingTypeMapper());
var deserializer = new JsonSerializer(_mappingRegistry);
var model = deserializer.Deserialize<TypeOfModel>(dataObject);

You can alternatively use an DefaultTypeMapper instead of the EverythingTypeMapper which will only attempt to serialize things with attributes on. The allowing you to not need any custom attributes. This is handy for scenarios where you just treat your models as pure data classes.

Only serialize certain properties

[Persist]
public class SomeClass
{
    [PersistData]
    public float SomeValue { get; set; }

    public string NotPersisted { get; set; }
}

var mappingRegistry = new MappingRegistry(new DefaultTypeMapper());
var serializer = new JsonSerializer(_mappingRegistry);
var output = serializer.Serialize(model);

Console.WriteLine("FileSize: " + output.AsString.Length + " bytes");
Console.WriteLine(output.AsString);

The [Persist] attribute indicates that this should be output in the serialized data, on a class it indicates it is a root object that contains serialized data, on a property it indicates the property should be mapped.

This attribute is used rather than [Serialize] because it is due to it being originally meant for ETL processes, if you want to just treat it like a serialization framework you can bypass the need for attributes entirely.

Docs

Check out the docs directory for docs which go into more detail.

Tests

There are a suite of unit tests which verify most scenarios, as well as output some performance related stats, it is recommended you take a peek at them if you want to see more advanced scenarios.

Blurb

This was originally part of the Persistity library for unity (which was originally part of EcsRx library), however was separated out to make more generic and reuseable and although its still meant to be used as a smaller part of a larger process, it has some helpers to allow it to be used just like a basic serializer without much effort.

The original focus of this library was to provide a consistent way to pass data around and convert/transform it between formats and types easily however as the serialization pieces can be used in isolation purely for serialization

Release Notes

Initial release

NuGet packages (6)

Showing the top 5 NuGet packages that depend on lazydata:

Package Downloads
lazydata.superlazy
A super lazy helper class to statically access serializers
LazyData.Numerics
Add default handling for System.Numerics.Vectors
LazyData.Json
Json serializer for use with LazyData
LazyData.Binary
Binary serializer for use with LazyData
LazyData.Xml
Xml serializer for use with LazyData

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
3.0.17 1,744 3/18/2020
2.0.11 855 12/19/2018
2.0.9 686 11/26/2018
1.1.7 717 11/15/2018
1.0.5 734 11/7/2018
1.0.3 698 11/7/2018
0.3.2 712 9/20/2018
0.3.1 705 9/20/2018
0.3.0 739 9/20/2018
0.2.21 546 9/18/2018
0.2.20 573 9/18/2018
0.2.19 571 9/18/2018
0.2.0 661 9/12/2018
0.1.0 549 2/16/2018
Show less