Utility function used to create a new instance from a JSON string.

@param array $json a PHP array which contains the result of a 'json_decode' execution.

@return \Gomoob\Pushwoosh\Model\Response\GetNearestZoneResponse the resulting instance.
435918
public static function create(array $json)
    {
        $getNearestZoneResponse = new GetNearestZoneResponse();
        $getNearestZoneResponse->setStatusCode($json['status_code']);
        $getNearestZoneResponse->setStatusMessage($json['status_message']);

        // If a 'response' is provided
        if (array_key_exists('response', $json) && isset($json['response'])) {
            $getNearestZoneResponseResponse = new GetNearestZoneResponseResponse();
            $getNearestZoneResponseResponse->setDistance($json['response']['distance']);
            $getNearestZoneResponseResponse->setLat($json['response']['lat']);
            $getNearestZoneResponseResponse->setLng($json['response']['lng']);
            $getNearestZoneResponseResponse->setName($json['response']['name']);
            $getNearestZoneResponseResponse->setRange($json['response']['range']);
            $getNearestZoneResponse->setResponse($getNearestZoneResponseResponse);
        }

        return $getNearestZoneResponse;
    }
1203969
protected function unsupportedActionResponse($json)
    {
        $error = new Error('Unsupported Action', json_decode($json));

        return $this->createResponse(new UnsupportedAction([$error]));
    }
329487
public function fromJson( $json )
	{
		$this->__construct();
		$data	= json_decode( $json, TRUE );
		foreach( $this->types as $key => $value )
			if( isset( $data[$key] ) )
				$this->types[$key]	= $data[$key];
	}
953623
public static function create(array $json)
    {
        $unregisterDeviceResponse = new UnregisterDeviceResponse();
        $unregisterDeviceResponse->setStatusCode($json['status_code']);
        $unregisterDeviceResponse->setStatusMessage($json['status_message']);

        return $unregisterDeviceResponse;
    }
884973
public static function buildFromJSON($json)
	{
		$jsonObject = json_decode($json);
		
		if(!property_exists($jsonObject, 'platformGID'))
			throw new SocialRecordFormatException('SocialRecord: Property platformGID missing!');
		if(!property_exists($jsonObject, 'globalID'))
			throw new SocialRecordFormatException('SocialRecord: Property globalID missing!');
		if(!property_exists($jsonObject, 'type'))
			throw new SocialRecordFormatException('SocialRecord: Property type missing!');
		if(!property_exists($jsonObject, 'displayName'))
			throw new SocialRecordFormatException('SocialRecord: Property displayName missing!');
		if(!property_exists($jsonObject, 'profileLocation'))
			throw new SocialRecordFormatException('SocialRecord: Property profileLocation missing!');
		if(!property_exists($jsonObject, 'personalPublicKey'))
			throw new SocialRecordFormatException('SocialRecord: Property personalPublicKey missing!');
		if(!property_exists($jsonObject, 'accountPublicKey'))
			throw new SocialRecordFormatException('SocialRecord: Property accountPublicKey missing!');
		if(!property_exists($jsonObject, 'salt'))
			throw new SocialRecordFormatException('SocialRecord: Property salt missing!');
		if(!property_exists($jsonObject, 'datetime'))
			throw new SocialRecordFormatException('SocialRecord: Property datetime missing!');
		if(!property_exists($jsonObject, 'active'))
			throw new SocialRecordFormatException('SocialRecord: Property active missing!');
		if(!property_exists($jsonObject, 'keyRevocationList'))
			throw new SocialRecordFormatException('SocialRecord: Property keyRevocationList missing!');
		
		$krl = array();
		
		foreach($jsonObject->keyRevocationList as $krc)
		{
			$krl[] = KeyRevocationCertificateBuilder::buildFromJSON($krc);
		}
		
		return (new SocialRecordBuilder())
				->type($jsonObject->type)
				->globalID($jsonObject->globalID)
				->platformGID($jsonObject->platformGID)
				->displayName($jsonObject->displayName)
				->profileLocation($jsonObject->profileLocation)
				->personalPublicKey(PublicKey::formatPEM($jsonObject->personalPublicKey))
				->accountPublicKey(PublicKey::formatPEM($jsonObject->accountPublicKey))
				->salt($jsonObject->salt)
				->datetime($jsonObject->datetime)
				->active($jsonObject->active)
				->keyRevocationList($krl)
				->build();
	}
665704
protected function jsonResponse($json = null)
    {
        if (!$json) {
            $json = $this->file instanceof Folder ? $this->parent->createFolderJson($this->file)
                : $this->parent->createFileJson($this->file);
        }

        $response = new SS_HTTPResponse(
            Convert::array2json($json), 200
        );

        return $response->addHeader('Content-Type', 'application/json');
    }
357674
public function decode($json)
    {
        $decoded = json_decode($json, true);
        if (null !== $decoded) {
            return $decoded;
        }
        if (JSON_ERROR_NONE === json_last_error()) {
            return $json;
        }

        return self::$json_errors[json_last_error()];
    }
1114709
function decodeJSON($json)
    {
        $json_response = json_decode($json);
        if ($json_response === null) {
            throw new Clientside\Exception("Unable to decode JSON response from: {$json}");
        }
        return $json_response;
    }
208592
public static function create($json)
    {
        $entity = json_decode($json);

        if (is_null($entity)) {
            throw new \InvalidArgumentException("Invalid JSON", 1);
        }

        $type = null;

        if (self::isObjectEntity($entity)) {
            $type = $entity->object;
        } elseif (self::isPeriodEntity($entity)) {
            $type = 'period';
        }

        if ($type == 'event') {
            return EventFactory::create($json);
        }

        $modelClass = self::isKnownEntityType($type)
            ? self::$objectTypeToModelClassMap[$type]
            : null;

        if (is_null($modelClass)) {
            throw new \OutOfRangeException('No model class found for object "'.$type.'"', 1);
        }

        if ($type == 'line_item') {
            $modelClass = $modelClass[$entity->type];
        }

        return new $modelClass($json);
    }
936827
private static function create($decoded, Json $json)
    {
        $json->validate(
            $json->decodeFile(PHAR_UPDATE_MANIFEST_SCHEMA),
            $decoded
        );

        $updates = array();

        foreach ($decoded as $update) {
            $updates[] = new Update(
                $update->name,
                $update->sha1,
                $update->url,
                Parser::toVersion($update->version),
                isset($update->publicKey) ? $update->publicKey : null
            );
        }

        usort(
            $updates,
            function (Update $a, Update $b) {
                return Comparator::isGreaterThan(
                    $a->getVersion(),
                    $b->getVersion()
                );
            }
        );

        return new static($updates);
    }
1036006
public function decode($json)
    {
        if (empty($json)) {
            return '';
        }
        $decoded = json_decode($json, true);
        if (null !== $decoded) {
            return $decoded;
        }
        if (JSON_ERROR_NONE === json_last_error()) {
            return $json;
        }

        return self::$jsonErrors[json_last_error()];
    }
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);
    }
  }
368497
public static function createFromJSON($json)
    {
        $object = json_decode($json);

        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new \Exception(
                'JSON parse had errors - ' . json_last_error_msg()
            );
        }

        return static::createFromObject($object);
    }
609054
public static function decode($json)
    {
        $flags = 0;
        if (PHP_INT_SIZE === 4) {
            $flags |= JSON_BIGINT_AS_STRING;
        }
        $data = json_decode($json, false, 512, $flags);
        $error = json_last_error();
        if ($error !== JSON_ERROR_NONE) {
            throw new \InvalidArgumentException(sprintf('Failed to decode JSON (%d): %s.', $error, json_last_error_msg()));
        }

        return $data;
    }
558838
public static function import_tour_from_json($json) {
        $tourconfig = json_decode($json);

        // We do not use this yet - we may do in the future.
        unset($tourconfig->version);

        $steps = $tourconfig->steps;
        unset($tourconfig->steps);

        $tourconfig->id = null;
        $tourconfig->sortorder = null;
        $tour = tour::load_from_record($tourconfig, true);
        $tour->persist(true);

        // Ensure that steps are orderered by their sortorder.
        \core_collator::asort_objects_by_property($steps, 'sortorder', \core_collator::SORT_NUMERIC);

        foreach ($steps as $stepconfig) {
            $stepconfig->id = null;
            $stepconfig->tourid = $tour->get_id();
            $step = step::load_from_record($stepconfig, true);
            $step->persist(true);
        }

        return $tour;
    }
1143673
public function decode(string $json)
    {
        // max depth is 0+ for json_encode(), and 1+ for json_decode()
        $result = json_decode($json, $this->decodeObjectAsArray, $this->maxDepth + 1, $this->options);

        $this->checkLastError();

        return $result;
    }
192133
static function FromString($json)
    {
        $jsonObj = @\json_decode($json);
        if (!is_a($jsonObj, 'stdClass')) {
            return null; 
        }
        $result = new static();
        $class = new \ReflectionClass($result);
        $props = $class->getProperties(\ReflectionProperty::IS_PUBLIC & ~ \ReflectionProperty::IS_STATIC);
        foreach ($props as $prop) {
            $name = $prop->getName();
            if (isset($jsonObj->$name)) {
                $prop->setValue($result, $jsonObj->$name);
            }
        }
        return $result;
    }