Download the PHP package kingson-de/marshal-json-serializer without Composer
On this page you can find all versions of the php package kingson-de/marshal-json-serializer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kingson-de/marshal-json-serializer
More information about kingson-de/marshal-json-serializer
Files in kingson-de/marshal-json-serializer
Package marshal-json-serializer
Short Description Marshal JSON Serializer will directly serialize the data to JSON, it is built on top of the Marshal Serializer.
License Apache-2.0
Informations about the package marshal-json-serializer
Marshal JSON Serializer
Introduction
Marshal JSON is serializing / marshalling data structures to JSON. It is also deserializing / unmarshalling JSON back to the data structures.
Installation
Easiest way to install the library is via composer:
The following PHP versions are supported:
- PHP 7.0
- PHP 7.1
- PHP 7.2
- PHP 7.3
Execute tests
Just run:
Or without code coverage:
Usage
How to create Data Structures which can be serialized?
Please check the Marshal Serializer README for more information.
How to use the Marshal JSON Serializer library?
The library provides several static methods to create your JSON data once you defined the data structures.
Deserializing / Unmarshalling
To transform JSON back to your structure use Marshal's deserialize functions. You need a class extending the AbstractObjectMapper which will be passed to the deserializeJson function. When using FlexibleData's get function it will throw an OutOfBoundsException if the key does not exist. If an exception is not needed the find function can be used which will return a custom default value in that case.
Another option would be to use the deserializeCallable function.
Modify existing JSON
An easy way to modify existing JSON is to use FlexibleData. Here is an example:
License
This project is released under the terms of the Apache 2.0 license.