jsonbuilder / jsonbuilder
DSL for generating JSON in PHP
Installs: 4 334
Dependents: 2
Suggesters: 1
Security: 0
Stars: 8
Watchers: 3
Forks: 2
Open Issues: 0
This package is not auto-updated.
Last update: 2023-11-25 09:34:08 UTC
README
DSL for generating JSON in PHP. Inspired by JBuilder.
Usage
use \jsonbuilder\JSONBuilder;
echo JSONBuilder::object(function($json) use($message) {
$json->id = $message->id;
$json->author = $message->author()->fullName();
$json->recipients($message->recipients(), function($json, $recipient) {
$json->id = $recipient->id;
$json->name = $recipient->fullName();
});
});
// {"id":1,"author":"John Doe","recipients":[{"id":5,"name":"Jane Doe"},{"id":9,"name":"Adam Smith"}]}
License
Licensed under the MIT License (http://www.opensource.org/licenses/mit-license.php)