Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

raymondjavaxx/jsonbuilder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSONBuilder

DSL for generating JSON in PHP. Inspired by JBuilder.

Build Status

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)