/** * @param string $jsonString * @return Result */ public static function fromJSON($jsonString) { Assertion::isJsonString($jsonString); $itemJsonStrings = json_decode($jsonString, true); $items = array(); foreach ($itemJsonStrings as $anItemJsonString) { $items[] = Item::fromJSON($anItemJsonString); } return new ItemCollection($items); $p = new Paginator(); }
public function testToAndFromJSON() { $listItem = new Item(array('array', 'to', 'json')); $jsonString = $listItem->toJSON(); $this->assertJson($jsonString); $listItemFromJSON = Item::fromJSON($jsonString); $this->assertTrue($listItem->sameValueAs($listItemFromJSON)); }