Unserializes the object from JSON.

@param string $json
The object as serialized using JSON.

@return DivideIQ
The unserialized object.
543162
public static function fromJson($json)
    {
        $data = json_decode($json);

        // Recreate the object.
        $object = new static($data->username, $data->password, $data->url);
        $object->authToken = Token::fromJson(json_encode($data->authToken));
        $object->accessToken = Token::fromJson(json_encode($data->accessToken));
        $object->refreshToken = Token::fromJson(json_encode($data->refreshToken));
        $object->settings = Settings::fromJson(json_encode($data->settings));

        return $object;
    }
267835
public function deserialize(string $json): WrapperInterface
    {
        try {
            /** @var WrapperInterface $wrapper */
            $wrapper = $this->jms()->deserialize(
                $json,
                $this->wrapperClass(),
                'json'
            );
        } catch (\Exception $e) {
            throw new \RuntimeException('Error while deserialize "' . $json . '"', 0, $e);
        }

        return $wrapper;
    }
66723
public function decode($json)
    {
        $decoded = json_decode($json, true);

        if (json_last_error() !== JSON_ERROR_NONE) {
            return null;
        }

        return $decoded;
    }
543565
public static function jsonDeserialize(string $json): self
    {
        $data = JSON::decode($json);

        if (empty($data['path'])) {
            throw new LogicException('The message does not contain "path" but it is required.');
        }

        if (empty($data['uris'])) {
            throw new LogicException('The message uris must not be empty array.');
        }

        return new static($data['path'], $data['uris']);
    }
845912
public static function RawSignedModelFromJson($json)
    {
        $body = json_decode($json, true);
        $signatures = $body['signatures'];

        $rawSignatures = [];
        foreach ($signatures as $signature) {
            $signatureSnapshot = null;
            if (array_key_exists('snapshot', $signature)) {
                $signatureSnapshot = $signature['snapshot'];
            }

            $rawSignatures[] = new RawSignature(
                $signature['signer'], base64_decode($signature['signature']), base64_decode($signatureSnapshot)
            );
        }


        return new RawSignedModel(base64_decode($body['content_snapshot']), $rawSignatures);
    }
864188
public function unserialize($serialized)
    {
        $objectData = unserialize($serialized);

        foreach ($objectData as $propertyName => $propertyValue)
        {
            $this->{$propertyName} = $propertyValue;
        }
    }
537630
public static function deserialize($json)
    {
        $data = json_decode($json);

        $template = new WidevineMessage();
        foreach ($data as $key => $value) {
            if ($key == 'content_key_specs') {
                $specs = [];
                foreach ($value as $child) {
                    $spec = new ContentKeySpecs();
                    foreach ($child as $cKey => $cValue) {
                        if ($cKey == 'required_output_protection') {
                            $rop = new RequiredOutputProtection();
                            if (isset($cValue->hdcp)) {
                                $rop->hdcp = $cValue->hdcp;
                            }
                            $spec->{$cKey} = $rop;
                        } else {
                            $spec->{$cKey} = $cValue;
                        }
                    }
                    $specs[] = $spec;
                }
                $template->content_key_specs = $specs;
            } else {
                $template->{$key} = $value;
            }
        }

        return $template;
    }
1249536
public static function decode($json)
    {
        $object = json_decode($json, true);
        if (json_last_error() !== JSON_ERROR_NONE) {
            $error = 'JSON error';
            if (function_exists('json_last_error_msg')) {
                $error = json_last_error_msg();
            } else { // @codeCoverageIgnoreStart
                switch (json_last_error()) {
                    case JSON_ERROR_DEPTH:
                        $error = 'maximum stack depth exceeded';
                        break;
                    case JSON_ERROR_STATE_MISMATCH:
                        $error = 'invalid or malformed JSON';
                        break;
                    case JSON_ERROR_CTRL_CHAR:
                        $error = 'control character error';
                        break;
                    case JSON_ERROR_SYNTAX:
                        $error = 'JSON syntax error';
                        break;
                    case JSON_ERROR_UTF8:
                        $error = 'malformed UTF-8 characters';
                        break;
                }
            } // @codeCoverageIgnoreEnd
            throw new JsonException($error);
        }
        return $object;
    }
930410
public function unserialize($data)
    {
        $object = @unserialize($data);
        if($object === false) {
            throw new SerializerException("Unable to unserialize data: " . $data);
        }

        return $object;
    }
962800
public static function fromJson($json){
    if(is_string($json)){
      $json = json_decode($json);
    }

    if (!isset($json->error) || is_null($json->error) ) {
      return new self($json->uuid, new DateTime($json->timestamp), $json->status);
    } else {
      if(!property_exists($json->error, 'code')){
        throw new BadResponseException('Required parameter "error.code" not found');
    }
      throw AbstractReport::errorToException($json->error->code);
    }
  }
224122
protected function compressInlineJsonCode($json)
    {
        if (!($json = (string) $json)) {
            return $json; // Nothing to do.
        }
        if (($compressed_json = \WebSharks\JsMinifier\Core::compress($json))) {
            return '/*<![CDATA[*/'.$compressed_json.'/*]]>*/';
        }
        return $json;
    }
884986
private function parseJson($json)
    {
        $jsonPayload = json_decode($json, true);

        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new ParserException('Error parsing JSON: '
                . json_last_error_msg());
        }

        return $jsonPayload;
    }
999130
public static function jsonDeserialize(array $json): DocumentSerializationInterface
    {
        $managerClass = $json['document_serialization']['manager_class'];
        $data = (array) $json['document_serialization']['data'];

        return new self($managerClass, $data);
    }
236908
public static function convert(array $json)
    {
        $loader  = new ArrayLoader;
        $package = $loader->load($json);


        if ($package instanceof CompletePackage) {
            return $package;
        }

        // @codeCoverageIgnoreStart
        throw new InvalidPackageException(
            'Expected instance of CompletePackage, got '.get_class($package)
        );
        // @codeCoverageIgnoreEnd
    }
1261847
public static function jsonToArray($json)
    {
        if (empty($json)) {
            return null;
        }

        $array = json_decode($json, true);

        switch (json_last_error()) {
            case JSON_ERROR_NONE:
                $message = null;
                break;

            case JSON_ERROR_STATE_MISMATCH:
                $message = 'Invalid or malformed JSON';
                break;

            case JSON_ERROR_UTF8:
                $message = 'Malformed UTF-8 characters, possibly incorrectly encoded';
                break;

            case JSON_ERROR_DEPTH:
                $message = 'The maximum stack depth has been exceeded';
                break;

            case JSON_ERROR_CTRL_CHAR:
                $message = 'Control character error, possibly incorrectly encoded';
                break;

            case JSON_ERROR_SYNTAX:
                $message = 'Syntax error, malformed JSON';
                break;

            default:
                $message = 'Unknown error';
                break;
        }

        if (!empty($message)) {
            throw new \InvalidArgumentException('JSON Error: ' . $message);
        }

        return $array;
    }
1249048
public static function fromJson($json){
    if(is_string($json)){
      $json = json_decode($json);
    }
    
    if(!property_exists($json, 'total')){
      throw new BadResponseException('Required parameter "total" not found');
    }
    if(!property_exists($json, 'fns_site')){
      throw new BadResponseException('Required parameter "fns_site" not found');
    }
    if(!property_exists($json, 'fn_number')){
      throw new BadResponseException('Required parameter "fn_number" not found');
    }
    if(!property_exists($json, 'shift_number')){
      throw new BadResponseException('Required parameter "shift_number" not found');
    }
    if(!property_exists($json, 'receipt_datetime')){
      throw new BadResponseException('Required parameter "receipt_datetime" not found');
    }
    if(!property_exists($json, 'fiscal_receipt_number')){
      throw new BadResponseException('Required parameter "fiscal_receipt_number" not found');
    }
    if(!property_exists($json, 'fiscal_document_number')){
      throw new BadResponseException('Required parameter "fiscal_document_number" not found');
    }
    if(!property_exists($json, 'fiscal_document_attribute')){
      throw new BadResponseException('Required parameter "fiscal_document_attribute" not found');
    }
    if(!property_exists($json, 'ecr_registration_number')){
      throw new BadResponseException('Required parameter "ecr_registration_number" not found');
    }

    return new self(
      $json->total,
      $json->fns_site,
      $json->fn_number,
      $json->shift_number,
      new DateTime($json->receipt_datetime),
      $json->fiscal_receipt_number,
      $json->fiscal_document_number,
      $json->fiscal_document_attribute,
      $json->ecr_registration_number
    );
  }
1254185
public static function load($json)
    {
        $j = new Json();

        return self::create($j->decode($json), $j);
    }