JSON5 Tools
Presenting a couple of JSON5 tools I built.
The first one was done a year ago, a docker CLI image to convert JSON5 to JSON: arokettu/json5-to-json.
A simple tool to convert your configs on the build phase without installing anything into your images.
The second one is a builder/serializer that is aimed at creating pretty configs in PHP: arokettu/json5-builder.
While it can just serialize some data into JSON5, the goal is to create nice configs with comments and custom formatting.
<?php use Arokettu\Json5\Json5Encoder; use Arokettu\Json5\Values\CommentDecorator; use Arokettu\Json5\Values\HexInteger; require __DIR__ . '/../vendor/autoload.php'; $config = new CommentDecorator( [ 'bareKeys' => '<- Look, no quotes!', 'value' => new CommentDecorator( new HexInteger(0xFFF), commentAfter: 'This is a very important value' ), 'notAvailableInJSON' => [NAN, INF], 'end' => 'auto trailing comma ->' ], commentBefore: 'This is my cool JSON5 config!', ); echo Json5Encoder::encode($config);
Comments
Comments powered by Disqus