You are here

class JsonCodec in N1ED - Visual editor as CKEditor plugin with Bootstrap support 7

Hierarchy

  • class \EdSDK\FileUploaderServer\lib\JsonCodec

Expanded class hierarchy of JsonCodec

2 files declare their use of JsonCodec
FlmngrServer.php in vendor/edsdk/flmngr-server-php/src/FlmngrServer.php
UploaderServlet.php in vendor/edsdk/file-uploader-server-php/src/servlet/UploaderServlet.php

File

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

Namespace

EdSDK\FileUploaderServer\lib
View source
class JsonCodec {
  protected $m_actions;
  public function __construct($actions) {
    $this->m_actions = $actions;
  }
  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;
  }
  public function toJson($resp) {
    return JsonCodec::s_toJson($resp);
  }
  public static function s_toJson($resp) {
    $json = json_encode($resp);
    $json = str_replace('\\u0000*\\u0000', '', $json);
    $json = str_replace('\\u0000', '', $json);
    return $json;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
JsonCodec::$m_actions protected property
JsonCodec::fromJson public function
JsonCodec::s_toJson public static function
JsonCodec::toJson public function
JsonCodec::__construct public function