public function JsonCodec::fromJson in N1ED - Visual editor as CKEditor plugin with Bootstrap support 8.2
Parses request JSON.
File
- src/
Flmngr/ FileUploaderServer/ lib/ JsonCodec.php, line 25
Class
- JsonCodec
- JSON coder/decoder. Converting objects to JSON and back with fixing some common encoding errors.
Namespace
Drupal\n1ed\Flmngr\FileUploaderServer\libCode
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->actions
->getAction($jsonObj->action);
if ($action === NULL) {
throw new Exception("JSON action is incorrect: " . $action);
}
return $jsonObj;
}