Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
--TEST-- Check for jsonschema vali ref --SKIPIF-- <?php if (!extension_loaded("jsons..
Decoded Output download
--TEST--
Check for jsonschema vali ref
--SKIPIF--
<?php
if (!extension_loaded("jsonschema")) {
print "skip";
}
?>
--FILE--
<?php
echo 'array list<map>:';
$value = array();
$value['users'][] = array('account' => 'userA', 'email' => '[email protected]');
$value['users'][] = array('account' => 'userB', 'email' => '[email protected]');
$value['users'][] = array('account' => 'userC', 'email' => '[email protected]');
$user_schema = array(
'id' => 'user',
'description' => 'user info',
'type' => 'object',
'optional' => true,
'properties' =>
array(
'account' =>
array(
'type' => 'string',
),
'email' =>
array(
'type' => 'string',
'optional' => true,
),
),
);
$schema = array(
'type' => 'object',
'properties' =>
array(
'users' =>
array(
'type' => 'array',
'items' =>
array(
'$ref' => 'user',
)
)
)
);
$jsonSchema = new JsonSchema();
$jsonSchema->addType($user_schema);
echo assert($jsonSchema->validate($schema, $value));
echo ',', assert($jsonSchema->validate(array(
'type' => 'object',
'properties' =>
array(
'users' =>
array(
'type' => 'array',
'items' =>
array(
'$ref' => 'user',
)
)
)
), $value)), PHP_EOL;
?>
--EXPECT--
array list<map>:1,1
Did this file decode correctly?
Original Code
--TEST--
Check for jsonschema vali ref
--SKIPIF--
<?php
if (!extension_loaded("jsonschema")) {
print "skip";
}
?>
--FILE--
<?php
echo 'array list<map>:';
$value = array();
$value['users'][] = array('account' => 'userA', 'email' => '[email protected]');
$value['users'][] = array('account' => 'userB', 'email' => '[email protected]');
$value['users'][] = array('account' => 'userC', 'email' => '[email protected]');
$user_schema = array(
'id' => 'user',
'description' => 'user info',
'type' => 'object',
'optional' => true,
'properties' =>
array(
'account' =>
array(
'type' => 'string',
),
'email' =>
array(
'type' => 'string',
'optional' => true,
),
),
);
$schema = array(
'type' => 'object',
'properties' =>
array(
'users' =>
array(
'type' => 'array',
'items' =>
array(
'$ref' => 'user',
)
)
)
);
$jsonSchema = new JsonSchema();
$jsonSchema->addType($user_schema);
echo assert($jsonSchema->validate($schema, $value));
echo ',', assert($jsonSchema->validate(array(
'type' => 'object',
'properties' =>
array(
'users' =>
array(
'type' => 'array',
'items' =>
array(
'$ref' => 'user',
)
)
)
), $value)), PHP_EOL;
?>
--EXPECT--
array list<map>:1,1
Function Calls
extension_loaded | 1 |
Stats
MD5 | 1825c2e1d6aba3e64e3d2fd96e7e5b2f |
Eval Count | 0 |
Decode Time | 108 ms |