Simple Use ########## .. highlight:: php Encode ====== ``\Arokettu\Json5\Json5Encoder::encode(mixed $value, Options $options = default)`` The method aims to be compatible with a simple |json_encode|_ dump. Important shared features: .. |json_encode| replace:: ``json_encode($value)`` .. _json_encode: https://www.php.net/manual/en/function.json-encode.php * |JsonSerializable|_ support. * Float precision depends on |serialize_precision|_ ini config. .. |JsonSerializable| replace:: ``JsonSerializable`` .. _JsonSerializable: https://www.php.net/manual/en/class.jsonserializable.php .. |serialize_precision| replace:: ``serialize_precision`` .. _serialize_precision: https://www.php.net/manual/en/ini.core.php#ini.serialize-precision The main differences: * ``NAN``, ``INF``, ``-INF`` float values are supported. * ``\Arokettu\Json5\Values\Json5Serializable`` interface that takes precedence in case you need different behavior for JSON and JSON5. * No generic object serialization is supported. An object must be an instance of ``stdClass`` or ``ArrayObject``, or implement ``JsonSerializable`` or ``Json5Serializable``. You can replicate the ``json_encode()`` behavior by wrapping an object with ``ArrayObject``. * The document is always pretty-printed. * Trailing commas are always used. Use :ref:`json5_options` and :ref:`json5_objects` to customize your output. How to prettify JSON ==================== You also need a parser, I will use `colinodell/json5 `_. Just parse and dump it:: composer.json5