json-builder

Allow to build JSON object programmatically

4 years after

JSON Builder

Allow to build a JSON string programmatically

Build Status Scrutinizer Code Quality

Table of contents

  1. Overview
  2. Installation
  3. Usage
  4. Known limitations
  5. Testing
  6. Contributing
  7. Authors
  8. License

Overview

<?php

require __DIR__ . '/vendor/autoload.php';

use JsonBuilder\Builder\JsonBuilder;

$jb = new JsonBuilder();
$root = $jb->root('array');
$root
    ->children()
        ->string()
            ->value('Foo')
        ->end()
        ->number()
            ->value(123)
        ->end()
    ->end()
->end();

$json = $jb->build()->toJson();

echo $json;

The above code will return

["Foo", 123]

Installation

Install the library package with composer:

$ php composer.phar require borisguery/json-builder

Usage

Known limitations

Testing

Install development dependencies

$ composer install --dev

Run the test suite

$ vendor/bin/phpunit

Contributing

  1. Take a look at the list of issues.
  2. Fork
  3. Write a test (for either new feature or bug)
  4. Make a PR

Authors

Boris Guéry - [email protected] - http://borisguery.com - @borisguery

License

This library is under the MIT license - see the LICENSE file for details

Related Repositories

json-parser

json-parser

Very low footprint JSON parser written in portable ANSI C ...

jsonify

jsonify

JSON builder ...

elasticsearch-river-streaming-json

elasticsearch-river-streaming-json

A sample elasticsearch river able to stream json data in ...

argonaut

argonaut

Lightweight JSON builder for Rails ...

jsonbuilder

jsonbuilder

Json builder which has the same interface with Builder::XmlMarkup ...