You are here

public function JsonCodec::fromJson in N1ED - Visual editor as CKEditor plugin with Bootstrap support 7

File

vendor/edsdk/file-uploader-server-php/src/lib/JsonCodec.php, line 22

Class

JsonCodec

Namespace

EdSDK\FileUploaderServer\lib

Code

public function fromJson($json) {
  $jsonObj = json_decode($json, false);
  if ($jsonObj === null) {
    throw new Exception('Unable to parse JSON');
  }
  if (!isset($jsonObj->action)) {
    throw new Exception('"Unable to detect action in JSON"');
  }
  $action = $this->m_actions
    ->getAction($jsonObj->action);
  if ($action === null) {
    throw new Exception("JSON action is incorrect: " . $action);
  }
  return $jsonObj;
}