All Projects → vaslabs → VSerializer

vaslabs / VSerializer

Licence: other
A library to serialize and deserialize objects with minimum memory usage.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to VSerializer

parco
🏇🏻 generalist, fast and tiny binary parser and compiler generator, powered by Go 1.18+ Generics
Stars: ✭ 57 (+128%)
Mutual labels:  serialization, deserialization
json struct
json_struct is a single header only C++ library for parsing JSON directly to C++ structs and vice versa
Stars: ✭ 279 (+1016%)
Mutual labels:  serialization, deserialization
marshmallow-validators
Use 3rd-party validators (e.g. from WTForms and colander) with marshmallow
Stars: ✭ 24 (-4%)
Mutual labels:  serialization, deserialization
Jsonapi Rails
Rails gem for fast jsonapi-compliant APIs.
Stars: ✭ 242 (+868%)
Mutual labels:  serialization, deserialization
nason
🗜 Ultra tiny serializer / encoder with plugin-support. Useful to build binary files containing images, strings, numbers and more!
Stars: ✭ 30 (+20%)
Mutual labels:  serialization, deserialization
avro-serde-php
Avro Serialisation/Deserialisation (SerDe) library for PHP 7.3+ & 8.0 with a Symfony Serializer integration
Stars: ✭ 43 (+72%)
Mutual labels:  serialization, deserialization
bytes
Work with bytes and implement network protocols
Stars: ✭ 77 (+208%)
Mutual labels:  serialization, deserialization
Dart Json Mapper
Serialize / Deserialize Dart Objects to / from JSON
Stars: ✭ 206 (+724%)
Mutual labels:  serialization, deserialization
cattrs
Complex custom class converters for attrs.
Stars: ✭ 565 (+2160%)
Mutual labels:  serialization, deserialization
serde
🚝 (unmaintained) A framework for defining, serializing, deserializing, and validating data structures
Stars: ✭ 49 (+96%)
Mutual labels:  serialization, deserialization
Jsonapi Rb
Efficiently produce and consume JSON API documents.
Stars: ✭ 219 (+776%)
Mutual labels:  serialization, deserialization
avrow
Avrow is a pure Rust implementation of the avro specification https://avro.apache.org/docs/current/spec.html with Serde support.
Stars: ✭ 27 (+8%)
Mutual labels:  serialization, deserialization
Schematics
Project documentation: https://schematics.readthedocs.io/en/latest/
Stars: ✭ 2,461 (+9744%)
Mutual labels:  serialization, deserialization
sqlathanor
Serialization / De-serialization support for the SQLAlchemy Declarative ORM
Stars: ✭ 105 (+320%)
Mutual labels:  serialization, deserialization
Mashumaro
Fast and well tested serialization framework on top of dataclasses
Stars: ✭ 208 (+732%)
Mutual labels:  serialization, deserialization
har-rs
A HTTP Archive format (HAR) serialization & deserialization library, written in Rust.
Stars: ✭ 25 (+0%)
Mutual labels:  serialization, deserialization
Aspjson
A fast classic ASP JSON parser and encoder for easy JSON manipulation to work with the new JavaScript MV* libraries and frameworks.
Stars: ✭ 165 (+560%)
Mutual labels:  serialization, deserialization
Marshmallow Jsonapi
JSON API 1.0 (https://jsonapi.org/) formatting with marshmallow
Stars: ✭ 203 (+712%)
Mutual labels:  serialization, deserialization
sexp-grammar
Invertible parsing for S-expressions
Stars: ✭ 28 (+12%)
Mutual labels:  serialization, deserialization
NBT
A java implementation of the NBT protocol, including a way to implement custom tags.
Stars: ✭ 128 (+412%)
Mutual labels:  serialization, deserialization

Android Arsenal

Deprecated

Please use https://github.com/vaslabs/VSerializerJVM instead.

VSerializer

A library to serialize and deserialize objects with minimum memory usage.

Gradle dependencies

allprojects {
		repositories {
			...
			maven { url "https://jitpack.io" }
		}
}
dependencies {
    compile 'com.github.vaslabs:VSerializer:2.3.1'
}

Example - Simple object

VSerializer vSerializer = new AlphabeticalSerializer();
TestUtils.AllEncapsulatedData allEncapsulatedData = new TestUtils.AllEncapsulatedData();
allEncapsulatedData.a = -1L;
allEncapsulatedData.b = 1;
allEncapsulatedData.c = 127;
allEncapsulatedData.d = -32768;
allEncapsulatedData.e = true;
allEncapsulatedData.f = 'h';

byte[] data = vSerializer.serialize(allEncapsulatedData);

TestUtils.AllEncapsulatedData recoveredData = 
	vSerializer.deserialise(data, TestUtils.AllEncapsulatedData.class);

#Example - List

List<TestUtils.EncapsulatedData> encapsulatedDataList = initList(...);
byte[] data = vSerializer.serialize(encapsulatedDataList);
List<TestUtils.EncapsulatedData> recoveredList = 
	vSerializer.deserialise(data, List.class, TestUtils.EncapsulatedData.class);

Motivation

Memory on Android is precious. Every application should be using the minimum available memory both volatile and persistent. However, the complexity of doing such a thing is too much for the average developer that wants to ship the application as fast as possible. The aim of this library is to automate the whole process and replace ideally the default serialization mechanism.

That can achieve:

  • Lazy compression and decompression on the fly to keep volatile memory usage low for objects that are not used frequently (e.g. cached objects with low hit/miss ratio).
  • Occupying less persistent memory when saving objects on disk.

How does it work?

This project is under development and very young. However, you can use it if you are curious or you want to be a step ahead by following the examples in the unit test classes.

Advantages

  • A lot less memory usage when serializing objects compared to JVM or json.
  • Faster processing for serialization/deserialization
  • Extensible: will be able to easily encrypt and decrypt your serialized objects
  • Out of the box deep cloning.

Disadvantages

  • Less forgiving for changed classes. A mechanism to manage changes will be in place but since the meta data for the classes won't be carried over it will never be the same as the defaults.
  • Does not maintain the object graph meaning that a cyclic data structure will not be possible to be serialized (The new version provides an experimental serializer that can serialize circular data structures. Use with care as it's still in beta.)
  • Loses polymorphism capabilities as it needs the exact class passed to deserialised methods in order to construct the object correctly
  • Reflection slows it down.

Example

circularDS = new CircularDS();
circularDS.pointsTo = circularDS;
circularDS.justANumber = 5;
VSerializer vSerializer = new ReferenceSensitiveAlphabeticalSerializer();
byte[] data = vSerializer.serialize(circularDS);
CircularDS recoveredCircularDS = vSerializer.deserialise(data, CircularDS.class);

Use case

  • Any data structure that matches a timestamp with other primitive values would be highly optimised in terms of space when saving the data using this approach. You can save millions of key/value pairs for data like timestamp/location history graph.
  • Short lived cache data are in less danger to cause problems when you do class changes. You can benefit by reducing the memory usage in your caching mechanism and not worry much about versioning problems.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].