All Projects → better-serializer → better-serializer

better-serializer / better-serializer

Licence: other
General serializer for PHP. An alternative to JmsSerializer.

Programming Languages

PHP
23972 projects - #3 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to better-serializer

id-mask
IDMask is a Java library for masking internal ids (e.g. from your DB) when they need to be published to hide their actual value and to prevent forging. It has support optional randomisation has a wide support for various Java types including long, UUID and BigInteger. This library bases its security on strong cryptographic primitives.
Stars: ✭ 39 (+44.44%)
Mutual labels:  serializer, jackson
Java
jsoniter (json-iterator) is fast and flexible JSON parser available in Java and Go
Stars: ✭ 1,308 (+4744.44%)
Mutual labels:  serializer, deserialization
Typical
Typical: Fast, simple, & correct data-validation using Python 3 typing.
Stars: ✭ 111 (+311.11%)
Mutual labels:  annotations, deserialization
Jackson Module Kotlin
Module that adds support for serialization/deserialization of Kotlin (http://kotlinlang.org) classes and data classes.
Stars: ✭ 830 (+2974.07%)
Mutual labels:  deserialization, jackson
Json Schema Validator
A fast Java JSON schema validator that supports draft V4, V6, V7 and V2019-09
Stars: ✭ 292 (+981.48%)
Mutual labels:  fast, jackson
Kripton
A Java/Kotlin library for Android platform, to manage bean's persistence in SQLite, SharedPreferences, JSON, XML, Properties, Yaml, CBOR.
Stars: ✭ 110 (+307.41%)
Mutual labels:  annotations, jackson
Go
A high-performance 100% compatible drop-in replacement of "encoding/json"
Stars: ✭ 10,248 (+37855.56%)
Mutual labels:  serializer, deserialization
Inquiry Deprecated
[DEPRECATED]: Prefer Room by Google, or SQLDelight by Square.
Stars: ✭ 264 (+877.78%)
Mutual labels:  annotations, deserialization
Flatsharp
Fast, idiomatic C# implementation of Flatbuffers
Stars: ✭ 133 (+392.59%)
Mutual labels:  serializer, deserialization
Lora Serialization
LoraWAN serialization/deserialization library for The Things Network
Stars: ✭ 120 (+344.44%)
Mutual labels:  serializer, deserialization
moonwlker
Jackson JSON without annotation.
Stars: ✭ 14 (-48.15%)
Mutual labels:  deserialization, jackson
Apex.Serialization
High performance contract-less binary serializer for .NET
Stars: ✭ 82 (+203.7%)
Mutual labels:  fast, serializer
Drf Typed Views
Use type annotations to validate/deserialize request parameters in Dango REST Framework.
Stars: ✭ 181 (+570.37%)
Mutual labels:  annotations, deserialization
Seriality
Seriality is a library for serializing and de-serializing all the Solidity types in a very efficient way which mostly written in solidity-assembly
Stars: ✭ 105 (+288.89%)
Mutual labels:  serializer, deserialization
Borer
Efficient CBOR and JSON (de)serialization in Scala
Stars: ✭ 131 (+385.19%)
Mutual labels:  fast, deserialization
jzon
A correct and safe JSON parser.
Stars: ✭ 78 (+188.89%)
Mutual labels:  serializer, deserialization
laravel5-hal-json
Laravel 5 HAL+JSON API Transformer Package
Stars: ✭ 15 (-44.44%)
Mutual labels:  serializer
jsonschema-generator
Java JSON Schema Generator – creating JSON Schema (Draft 6, Draft 7, Draft 2019-09, or Draft 2020-12) from Java classes
Stars: ✭ 213 (+688.89%)
Mutual labels:  jackson
hash-wasm
Lightning fast hash functions using hand-tuned WebAssembly binaries
Stars: ✭ 382 (+1314.81%)
Mutual labels:  fast
schema-gen
XML Schema code generator outputting Swift, Kotlin and Java
Stars: ✭ 25 (-7.41%)
Mutual labels:  jackson

BetterSerializer (PHP)

Build Status Coverage Status Latest Stable Version Total Downloads Latest Unstable Version License composer.lock available Appveyor status

This library provides a general serializer for PHP. Currently only JSON serialization format is supported. The project aims to be an alternative to JmsSerializer. It tries to be faster then JmsSerializer and it also tries to sustain a better maintainable and understandable code base. Also, as this is also a learning experiment, one of the goals is to have unit tests with 100% code coverage.

Except the above mentioned goals, the project also aims to provide some cool features - it tries to combine the best features from JmsSerializer and from Jackson in Java.

Current state

Currently, only JSON de/serialization is implemented. It's possible to de/serialize complex nested data structures (objects and arrays). Only arrays are supported as collection types for now.

Performance

For now the code is only a proof of concept, but it is stabilizing more and more each day. It already yields interesting results. Without implementing metadata caching, the serialization process is already 4-6x faster than using JmsSerializer. The deserialization process is also faster, but only cca 3.5x faster.

There is also another benchmark, which compares JMS Serializer, Ivory Serializer and Better Serialier. It also integrates Symfony serializer, but I needed to comment it out, because it was 100-300x slower than Better Serializer. You can find a fork of it here and try it on your own. For best results, please disable XDebug while running the tests.

Here are some of the results:

$ php bin/benchmark  --iteration 1000 --horizontal-complexity 2 --vertical-complexity 2
Ivory: Done!
JMS: Done!
BetterSerializer: Done!

+------------------+----------------+--------+
| Serializer       | Duration (sec) | Factor |
+------------------+----------------+--------+
| BetterSerializer | 0.001188s      | 1.00x  |
| Ivory            | 0.002222s      | 1.87x  |
| JMS              | 0.002901s      | 2.44x  |
+------------------+----------------+--------+

$ php bin/benchmark  --iteration 100 --horizontal-complexity 10 --vertical-complexity 10
Ivory: Done!
JMS: Done!
BetterSerializer: Done!

+------------------+----------------+--------+
| Serializer       | Duration (sec) | Factor |
+------------------+----------------+--------+
| BetterSerializer | 0.011377s      | 1.00x  |
| Ivory            | 0.037377s      | 3.29x  |
| JMS              | 0.046837s      | 4.12x  |
+------------------+----------------+--------+

$ php bin/benchmark  --iteration 1 --horizontal-complexity 100 --vertical-complexity 200
Ivory: Done!
JMS: Done!
BetterSerializer: Done!

+------------------+----------------+--------+
| Serializer       | Duration (sec) | Factor |
+------------------+----------------+--------+
| BetterSerializer | 1.040695s      | 1.00x  |
| Ivory            | 4.191479s      | 4.03x  |
| JMS              | 4.466160s      | 4.29x  |
+------------------+----------------+--------+

$ php bin/benchmark  --iteration 1 --horizontal-complexity 200 --vertical-complexity 200
Ivory: Done!
JMS: Done!
BetterSerializer: Done!

+------------------+----------------+--------+
| Serializer       | Duration (sec) | Factor |
+------------------+----------------+--------+
| BetterSerializer | 4.523851s      | 1.00x  |
| Ivory            | 15.580491s     | 3.44x  |
| JMS              | 18.571867s     | 4.11x  |
+------------------+----------------+--------+

This means that you can now effectively de/serialize 4x more entities (e.g. in API results) using the same amount of time than before!

Regarding the performance gains - I'd like someone to check the measured values, since the results seem quite great and I'm suspicious myself :).

Features

You can check out the features in the features page. Please also check the supported annotations documentation.

Requirements

This library requires PHP 7.2 and it won't work with older versions. Older versions won't be supported.

Usage

The usage is described here.

The de/serializaton annotations are described here.

If you'd like to write custom extensions for special de/serialising of selected data types, check the extensions section

Future Plans

  • metadata caching
  • XML and YAML support
  • various collection classes support (Doctrine collections, internal PHP collections like SplStack)
  • data injection using class constructors (internal and static), which should improve performance even more
  • various features import from JmsSerializer and Jackson
  • framework integrations

Contributions are welcome! :)

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].