Imports VCard from JSON String.
@access		public
@param		string		$json					JSON String
@return		void
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];
	}
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;
    }
650379
public function checkSyntax($json)
    {
        $parser = new JsonParser;

        if (($result = $parser->lint($json)) instanceof ParsingException) {
            throw $result;
        }
    }
368545
public static function fromJson($json)
    {
        $object = json_decode($json);

        $recurrentPayment = new RecurrentPayment();

        if (isset($object->RecurrentPayment)) {
            $recurrentPayment->populate($object->RecurrentPayment);
        }

        return $recurrentPayment;
    }
818366
private static function saveFile($file, $json)
    {
        if (@file_put_contents($file, $json) === false) {
            $message = 'Could not create file in';
            throw new JsonException($message . ' ' . $file);
        }
    }
278196
private function jsonToArray($json)
	{
		try {
			$data = json_decode($json, true);
			if(is_array($data)) {
				return $data;
			}
			else {
				$this->error = 'The given data string was not json';
				return [];
			}
		}
		catch(Exception $e) {
			$this->error = $e;
		}
	}
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;
    }
767532
protected static function throwDecodingExceptionIfOccurred($json)
    {
        if (JSON_ERROR_NONE === json_last_error()) {
            return;
        }

        $decodingException = new DecodingException(
            sprintf('JSON decoding failed: %s', json_last_error_msg()),
            json_last_error()
        );

        $decodingException->setDecodingData($json);

        throw $decodingException;
    }
1272112
public static function decode(string $json)
    {
        $value = json_decode($json, true, 512, JSON_BIGINT_AS_STRING);

        if ($error = json_last_error()) {
            throw new JsonException(json_last_error_msg(), $error);
        }

        return $value;
    }
186328
public static function fromJson($json)
    {
        $responseData = json_decode($json, true);

        if (! $responseData) {
            return new Response(false, ['invalid-json']);
        }

        if (isset($responseData['success']) && $responseData['success'] == true) {
            return new Response(true);
        }

        if (isset($responseData['error-codes']) && is_array($responseData['error-codes'])) {
            return new Response(false, $responseData['error-codes']);
        }

        return new Response(false);
    }
958485
public function loadJson($file, $dir = null)
    {
        if (empty($file)) {
            throw new Exception('loadJson Error: File name not set');
        }

        if (! file_exists($file) && ! file_exists($file = $this->dataDir("/$dir/".strtolower($file).'.json'))) {
            return coollect();
        }

        $decoded = json5_decode($this->loadFile($file), true);

        if (is_null($decoded)) {
            throw new Exception("Error decoding json file: $file");
        }

        return coollect($decoded);
    }
1205769
private static function jsonFileDecode($string)
    {
        $json = JsonHelper::decodeIfJson($string);
        if (\is_string($json)) {
            Craft::error('Error decoding JSON file: '.$json, __METHOD__);
            $json = null;
        }

        return $json;
    }
1017383
protected function jsonDecode($json)
    {
        // From firebase/php-jwt
        if (!(defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)) {
            /**
             * In PHP >=5.4.0, json_decode() accepts an options parameter, that allows you
             * to specify that large ints (like Steam Transaction IDs) should be treated as
             * strings, rather than the PHP default behaviour of converting them to floats.
             */
            $obj = json_decode($json, false, 512, JSON_BIGINT_AS_STRING);
        } else {
            // @codeCoverageIgnoreStart
            /**
             * Not all servers will support that, however, so for older versions we must
             * manually detect large ints in the JSON string and quote them (thus converting
             * them to strings) before decoding, hence the preg_replace() call.
             * Currently not sure how to test this so I ignored it for now.
             */
            $maxIntLength = strlen((string) PHP_INT_MAX) - 1;
            $jsonWithoutBigints = preg_replace('/:\s*(-?\d{'.$maxIntLength.',})/', ': "$1"', $json);
            $obj = json_decode($jsonWithoutBigints);
            // @codeCoverageIgnoreEnd
        }

        return $obj;
    }
61673
private function LoadFromJSON($path)
    {
        $this->definitions_path = rtrim($path, "/\\") . "/";
        $this->import_type = Type::JSON;

        if(file_exists($this->definitions_path . "constants.json"))
        {
            $this->SendMessage(t("Loading constants.json"));
            $this->LoadConstantsFromJson();
        }
        
        if(file_exists($this->definitions_path . "enumerations.json"))
        {
            $this->SendMessage(t("Loading enumerations.json"));
            $this->LoadEnumerationsFromJson();
        }
        
        if(file_exists($this->definitions_path . "type_definitions.json"))
        {
            $this->SendMessage(t("Loading type_definitions.json"));
            $this->LoadTypeDefFromJson();
        }
        
        if(file_exists($this->definitions_path . "variables.json"))
        {
            $this->SendMessage(t("Loading variables.json"));
            $this->LoadGlobalVariablesFromJson();
        }
        
        if(file_exists($this->definitions_path . "functions.json"))
        {
            $this->SendMessage(t("Loading functions.json"));
            $this->LoadFunctionsFromJson();
        }
        
        if(file_exists($this->definitions_path . "classes.json"))
        {
            $this->SendMessage(t("Loading classes.json"));
            $this->LoadClassesFromJson();
        }
    }
982490
protected static function _parse_json($json) {
    $rval = json_decode($json);
    $error = json_last_error();
    if($error === JSON_ERROR_NONE && $rval === null) {
      $error = JSON_ERROR_SYNTAX;
    }
    switch($error) {
    case JSON_ERROR_NONE:
      break;
    case JSON_ERROR_DEPTH:
      throw new JsonLdException(
        'Could not parse JSON; the maximum stack depth has been exceeded.',
        'jsonld.ParseError');
    case JSON_ERROR_STATE_MISMATCH:
      throw new JsonLdException(
        'Could not parse JSON; invalid or malformed JSON.',
        'jsonld.ParseError');
    case JSON_ERROR_CTRL_CHAR:
    case JSON_ERROR_SYNTAX:
      throw new JsonLdException(
        'Could not parse JSON; syntax error, malformed JSON.',
        'jsonld.ParseError');
    case JSON_ERROR_UTF8:
      throw new JsonLdException(
        'Could not parse JSON from URL; malformed UTF-8 characters.',
        'jsonld.ParseError');
    default:
      throw new JsonLdException(
        'Could not parse JSON from URL; unknown error.',
        'jsonld.ParseError');
    }
    return $rval;
  }
1282710
public static function fromJson($json)
    {
        $data = json_decode($json);

        $expireDate = is_null($data->expire) ? null : new \DateTime($data->expire, new \DateTimeZone('UTC'));

        // Recreate the object.
        return new static($data->token, $expireDate);
    }
640044
private function processJson($json)
    {
        $twee_array = json_decode($json, true);

        if (!isset($twee_array['data']) or empty($twee_array['data'])) {
            throw new RuntimeException("The provided JSON did not decode or is empty.");
        }

        foreach ($twee_array['data'] as $entity) {
            $type = $this->getTypeFromTags($entity['tags']);
            if (empty($type)) {
                $type = $this->getTypeFromTitle($entity['title']);
            }
            switch ($type) {
                case 'passage':
                    $passage = new TweePassage($entity);
                    $this->passages[$passage->title] = $passage;
                    // Set the start passage
                    if (in_array('start', $passage->tags)) {
                        $this->current_passage = $passage->title;
                        $this->history[] = $this->current_passage;
                        $this->storyline[] = $this->current_passage;
                    }
                    break;
                case 'title':
                    $this->title = $entity['text'];
                    break;
                case 'script':
                    $this->scripts[] = $entity['text'];
                    break;
                case 'stylesheet':
                    $this->stylesheets[] = $entity['text'];
                    break;
                default:
                    throw new \RuntimeException("Unknown entity type!");
            }
        }
        return true;
    }