You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
709 B
PHP
34 lines
709 B
PHP
<?php
|
|
|
|
/**
|
|
* @internal
|
|
*/
|
|
class SageParsersJson implements SageParserInterface
|
|
{
|
|
public function replacesAllOtherParsers()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public function parse(&$variable, $varData)
|
|
{
|
|
if (! SageHelper::isRichMode()
|
|
|| ! SageHelper::php53orLater()
|
|
|| ! is_string($variable)
|
|
|| ! isset($variable[0])
|
|
|| ($variable[0] !== '{' && $variable[0] !== '[')
|
|
|| ($json = json_decode($variable, true)) === null
|
|
) {
|
|
return false;
|
|
}
|
|
|
|
$val = (array)$json;
|
|
|
|
if (empty($val)) {
|
|
return false;
|
|
}
|
|
|
|
$varData->addTabToView($variable, 'Json', $val);
|
|
}
|
|
}
|