mirror of
https://github.com/SociallyDev/Spaces-API.git
synced 2025-08-14 02:27:23 -07:00
spaces.php
This commit is contained in:
parent
7755490b81
commit
eefa32741e
845 changed files with 50409 additions and 0 deletions
58
aws/Aws/Api/Parser/JsonParser.php
Normal file
58
aws/Aws/Api/Parser/JsonParser.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
namespace Aws\Api\Parser;
|
||||
|
||||
use Aws\Api\DateTimeResult;
|
||||
use Aws\Api\Shape;
|
||||
|
||||
/**
|
||||
* @internal Implements standard JSON parsing.
|
||||
*/
|
||||
class JsonParser
|
||||
{
|
||||
public function parse(Shape $shape, $value)
|
||||
{
|
||||
if ($value === null) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
switch ($shape['type']) {
|
||||
case 'structure':
|
||||
$target = [];
|
||||
foreach ($shape->getMembers() as $name => $member) {
|
||||
$locationName = $member['locationName'] ?: $name;
|
||||
if (isset($value[$locationName])) {
|
||||
$target[$name] = $this->parse($member, $value[$locationName]);
|
||||
}
|
||||
}
|
||||
return $target;
|
||||
|
||||
case 'list':
|
||||
$member = $shape->getMember();
|
||||
$target = [];
|
||||
foreach ($value as $v) {
|
||||
$target[] = $this->parse($member, $v);
|
||||
}
|
||||
return $target;
|
||||
|
||||
case 'map':
|
||||
$values = $shape->getValue();
|
||||
$target = [];
|
||||
foreach ($value as $k => $v) {
|
||||
$target[$k] = $this->parse($values, $v);
|
||||
}
|
||||
return $target;
|
||||
|
||||
case 'timestamp':
|
||||
// The Unix epoch (or Unix time or POSIX time or Unix
|
||||
// timestamp) is the number of seconds that have elapsed since
|
||||
// January 1, 1970 (midnight UTC/GMT).
|
||||
return DateTimeResult::fromEpoch($value);
|
||||
|
||||
case 'blob':
|
||||
return base64_decode($value);
|
||||
|
||||
default:
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue