Codifica el parámetro a JSON.
@param string $json
@param boolean $toObject
@return array
191642
public function decode($json, $toObject = FALSE)
    {
        if (is_file($json)) {
            if (is_readable($json)) {
                $json = file_get_contents($json);
            } else {
                throw new \ErrorException(self::ERROR_CANNOT_READ_FILE);
            }
        }

        $value = json_decode($json, !$toObject);

        if ($code = json_last_error()) $this->throwError($code);

        return $value;
    }
695347
public function convert(string $json, bool $externalJs = true)
    {
        // convert the json to an associative array
        $input = json_decode($json, true);
        $text = '';
        $codejs = [];

        if (empty($this->view)) {
            $this->view = 'sirtrevorjs::html';
        }

        if (is_array($input)) {
            // blocks
            $blocks = $this->getBlocks();

            // loop trough the data blocks
            foreach ($input['data'] as $block) {
                // no data, problem
                if (!isset($block['data']) || !array_key_exists($block['type'], $blocks)) {
                    break;
                }

                $class = $blocks[$block['type']];
                $converter = new $class($this->parser, $this->config, $block, $this->output);
                $converter->setView($this->view);
                $text .= $converter->render();
                $codejsClass = $converter->getCodeJs();

                if (is_array($codejsClass)) {
                    $codejs = array_merge($codejs, $codejsClass);
                }
            }

            // code js
            if ($externalJs && is_array($codejs)) {
                $text .= implode($codejs);
            }

            $this->codeJs = implode($codejs);
        }

        return $text;
    }
326961
public static function convertFromJSON($json)
    {
        $object = json_decode($json, true);
        $bencode = self::encode($object);

        return $bencode;
    }
1294186
public static function jsonDeserialize( $json ) {
		$self = new LogList();
		foreach ( $json as $logJson ) {
			$self->addLog( Log::jsonDeserialize( $logJson ) );
		}
		return $self;
	}
654924
private function template($toObject)
	{
		if($toObject) {
			$response = new StdClass;

			foreach($this->returnLocationData as $key => $value) {
				$response->{$key} = $value;
			}
			return $response;
		}
		return $this->returnLocationData;
	}
1336845
public static function jsonDeserialize( $json ) {
		return new self(
			$json['id'],
			$json['type'],
			$json['action'],
			$json['timestamp'],
			$json['user'],
			PageIdentifier::jsonDeserialize( $json['pageidentifier'] ),
			$json['comment'],
			$json['details']
		);
	}
415855
public static <T> T toObject(String json, Class<T> clazz) {
        if (json == null || json.trim().length() == 0) {
            return null;
        }
        T t = null;
        try {
            t = JSON.parseObject(json, clazz);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return t;
    }
543302
public function json($assoc = false, $fromEncoding = null, $toEncoding = 'UTF-8')
    {
        return json_decode($this->body($fromEncoding, $toEncoding), $assoc);
    }
159083
public function decode(string $json, bool $assoc = null, int $depth = null, int $options = null)
    {
        list($content, $error) = $this->softDecode($json, $assoc, $depth, $options);
        if ($error !== null) {
            throw $error;
        }
        return $content;
    }
870953
public function jsonSerialize($object, $data = [], $options = []): array
    {
        $class = \get_class($object);

        $rc = new \ReflectionClass($object);

        // get values of properties
        if (isset($options['includeProperties']) && $options['includeProperties']) {
            foreach ($rc->getProperties() as $reflectionProperty) {
                $propertyName = $reflectionProperty->getName();

                $property = $rc->getProperty($propertyName);

                if (isset($options['ignorePropertyVisibility']) && $options['ignorePropertyVisibility']) {
                    $property->setAccessible(true);
                }

                $data[$propertyName] = $property->getValue($object);

                if (\is_object($data[$propertyName])) {
                    if (!($data[$propertyName] instanceof \JsonSerializable)) {
                        unset($data[$propertyName]);

                        continue;
                    }

                    $data[$propertyName] = $this->jsonSerialize($data[$propertyName]);
                }
            }
        }

        if (isset($options['ignoreMethods']) && $options['ignoreMethods']) {
            return $data;
        }

        // get values of methods
        if (isset($options['ignoreMethodVisibility']) && $options['ignoreMethodVisibility']) {
            $methods = $rc->getMethods();
        } else {
            $methods = $rc->getMethods(\ReflectionMethod::IS_PUBLIC);
        }

        // add all public getter Methods
        foreach ($methods as $method) {
            // get()
            if (false !== ('get' === substr($method->name, 0, \strlen('get')))) {
                $start = 3; // highest priority
            } // is()
            elseif (false !== ('is' === substr($method->name, 0, \strlen('is')))) {
                $name = substr($method->name, 2, \strlen($method->name));
                $start = !$rc->hasMethod('has'.ucfirst($name)) && !$rc->hasMethod('get'.ucfirst($name)) ? 2 : 0;
            } elseif (false !== ('has' === substr($method->name, 0, \strlen('has')))) {
                $name = substr($method->name, 3, \strlen($method->name));
                $start = !$rc->hasMethod('is'.ucfirst($name)) && !$rc->hasMethod('get'.ucfirst($name)) ? 3 : 0;
            } else {
                continue;
            }

            // skip methods with parameters
            $rm = new \ReflectionMethod($class, $method->name);

            if ($rm->getNumberOfRequiredParameters() > 0) {
                continue;
            }

            if (isset($options['skippedMethods']) && \is_array($options['skippedMethods']) && \in_array($method->name, $options['skippedMethods'])) {
                continue;
            }

            $property = lcfirst(substr($method->name, $start));

            $data[$property] = $object->{$method->name}();

            if (\is_object($data[$property])) {
                if (!($data[$property] instanceof \JsonSerializable)) {
                    unset($data[$property]);

                    continue;
                }
                $data[$property] = $this->jsonSerialize($data[$property]);
            }
        }

        return $data;
    }
557384
public function get($toObject = false)
	{
        if(!env('GOOGLE_KEY')) {
            throw new Exception("Need an env key for geo request", 401);
        }

		$this->response = null;
		$this->error = null;

		if($this->c2a()) {
			$response = $this->template($toObject);
		}
		elseif($this->a2c()) {
			$response = $this->template($toObject);
		}
		elseif($this->i2c()) {
			$response = $this->template($toObject);
		}
		elseif($this->p2c()) {
			$response = $this->template($toObject);
		}

		if($response) {
			$this->reset();
			return $response;
		}

		throw new Exception(trans('location::errors.not_enough_data'));
	}
1132700
public static function decode($json, array $context = [])
    {
        $context = array_merge(static::$defaultDecodeContext, $context);

        return static::decodeData($json, $context);
    }
429355
public static function get_Json( &$json )
    {
        if( $json instanceof Json ) {
            return $json;
        }
        return !is_null($json)
            ? new Json($json)
            : null
            ;
    }
388322
public static function fromJson($json) {
        if (!$json) {
            $json = array();
        }

        if (!is_array($json)) {
            if (is_object($json)) {
                $json = (array) $json;
            } elseif (is_string($json)) {
                $json = json_decode(trim($json) ? $json : '{}', true);
            } else {
                throw new \InvalidArgumentException("JSON must be a string, an array or an object ('" . gettype($json) . "' provided).");
            }
        }

        return new Link(
            isset($json['href'])        ? $json['href']            : null,
            isset($json['templated'])    ? $json['templated']    : null,
            isset($json['type'])        ? $json['type']            : null,
            isset($json['deprecation'])    ? $json['deprecation']    : null,
            isset($json['name'])        ? $json['name']            : null,
            isset($json['profile'])        ? $json['profile']        : null,
            isset($json['title'])        ? $json['title']        : null,
            isset($json['hreflang'])    ? $json['hreflang']        : null
        );
    }
288522
private function simple_json_parser($json){
        $json = str_replace("{","",str_replace("}","", $json));
        $jsonValue = explode(",", $json);
        $arr = array();
        foreach($jsonValue as $v){
            $jValue = explode(":", $v);
            $arr[str_replace('"',"", $jValue[0])] = (str_replace('"', "", $jValue[1]));
        }
        return $arr;
    }
99884
public function map($json, $object)
    {
        foreach ($json as $key => $jvalue) {
            $key = $this->getSafeName($key);
            $setter = 'set' . $this->getCamelCaseName($key);
            if (method_exists($object, $setter)) {
                $object->{$setter}($jvalue);
            }
        }

        return $object;

    }
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;
		}
	}