toJson() public method

Converts the current object into a json string
public toJson ( ) : string
return string
Example #1
0
<?php

require_once 'Arr.php';
require_once 'Collection.php';
$foo = array('name' => 'haicheng', 'age' => '28');
$foo_collection = new Collection($foo);
echo $foo_collection->toJson();
$foo_collection->add('foo1', '1');
$foo_collection->add('foo2.foo1-1', '2');
echo $foo_collection->toJson();
var_dump($foo_collection->getIterator());
 public function testToJson()
 {
     $this->assertEquals('[{"first_name":"john","last_name":"smith","age":44},{"first_name":"kara","last_name":"trace","age":27},{"first_name":"phil","last_name":"mcKay","age":34},{"first_name":"rose","last_name":"smith","age":27}]', $this->collection->toJson());
 }