Back
[
{
"CUSTOM_ID": 1,
"name": "First"
},
{
"CUSTOM_ID": 2,
"name": "Second"
},
{
"CUSTOM_ID": 3
}
]
use Matraux\JsonOrm\Json\SimpleExplorer;
$explorer = SimpleExplorer::fromFile('path to JSON file'); // Access data from file
$explorer = SimpleExplorer::fromString('JSON string'); // Access data from string
$collection = CommonCollection::fromExplorer($explorer); // Create collection
/**
* ArrayAccess
*/
$entity = $collection[0];
echo $entity->id; // Print 1
echo $entity->name; // Print "First"
$time = $entity->timestamp; // null|DateTime object
/**
* Iterator
*/
foreach($collection as $entity) {
echo $entity->id; // Print 1, 2 and 3
echo $entity->name; // Print "First", "Second" and null
}
echo count($collection); // Print count of entities
{
"CUSTOM_ID": 1,
"name": "First"
}
use Matraux\JsonOrm\Json\SimpleExplorer;
$explorer = SimpleExplorer::fromFile('path to JSON file'); // Access data from file
$explorer = SimpleExplorer::fromString('JSON string'); // Access data from string
$entity = CommonEntity::fromExplorer($explorer);
echo $entity->id; // Print "1"
echo $entity->name; // Print "First"
$time = $entity->timestamp; // null|DateTime object