@param string $jsonString

@return array
191828
public static function decode($jsonString)
    {
        $jsonData = json_decode($jsonString, true);
        if (null === $jsonData && JSON_ERROR_NONE !== json_last_error()) {
            throw new JsonException('unable to parse/decode JSON');
        }

        if (!\is_array($jsonData)) {
            throw new JsonException(sprintf('expected JSON object, got "%s"', \gettype($jsonData)));
        }

        return $jsonData;
    }
1179942
public static function fromJson(string $jsonString): ApiContext
    {
        $apiContext = new static();
        $contextJson = \GuzzleHttp\json_decode($jsonString, true);
        $apiContext->environmentType = new BunqEnumApiEnvironmentType($contextJson[self::FIELD_ENVIRONMENT_TYPE]);
        $apiContext->apiKey = $contextJson[self::FIELD_API_KEY];
        $apiContext->proxyUrl = static::restoreProxyUrl($contextJson);
        $apiContext->installationContext = InstallationContext::restore($contextJson[self::FIELD_INSTALLATION_CONTEXT]);
        $apiContext->sessionContext = SessionContext::restore($contextJson[self::FIELD_SESSION_CONTEXT]);

        return $apiContext;
    }
786829
public function determineCompletedLanguages(JsonDocument $jsonDocument)
    {
        $jsonDocument = $this->polyFillMultilingualFields($jsonDocument);
        return parent::determineCompletedLanguages($jsonDocument);
    }
812143
public function theResponseShouldContainJson(PyStringNode $jsonString)
    {
        $etalon = json_decode($this->replacePlaceHolder($jsonString->getRaw()), true);
        $actual = json_decode($this->response->getBody(), true);

        if (null === $etalon) {
            throw new \RuntimeException(
              "Can not convert etalon to json:\n" . $this->replacePlaceHolder($jsonString->getRaw())
            );
        }

        if (null === $actual) {
            throw new \RuntimeException(
              "Can not convert actual to json:\n" . $this->replacePlaceHolder((string) $this->response->getBody())
            );
        }

        Assertions::assertGreaterThanOrEqual(count($etalon), count($actual));
        foreach ($etalon as $key => $needle) {
            Assertions::assertArrayHasKey($key, $actual);
            Assertions::assertEquals($etalon[$key], $actual[$key]);
        }
    }
1344990
public function parseJsonString(string $jsonString, string $entityClassName, array $sortColumns = null): ParsedRuleGroup
    {
        $doctrineParser = $this->newParser($entityClassName);

        return $doctrineParser->parse($this->jsonDeserializer->deserialize($jsonString), $sortColumns);
    }
77760
public function decodeJson($string)
    {
        return json_decode(
            $string,
            $this->format->isJsonDecodeAssoc(),
            static::JSON_DEFAULT_DEPTH,
            $this->format->getJsonDecodeOptions()
        );
    }
885494
public function getJson($jsonFile, $jsonSchema = null)
    {
        if (isset($jsonSchema) && array_key_exists($jsonSchema, $this->validation)) {
            $validation = $this->validation[$jsonSchema];
        } elseif ($jsonSchema === null) {
            $validation = $jsonSchema;
        } else {
            throw new Exception('Invalid jsonSchema validation key');
        }

        try {
            return $this->decodeFile($jsonFile, $validation);
        } catch (\RuntimeException $e) {
            // Runtime errors such as file not found
            $this->errors[] = $e->getMessage();
        } catch (ValidationFailedException $e) {
            // Schema validation errors
            $this->errors[] = $e->getMessage();
        } catch (\Exception $e) {
            // Anything else we did not anticipate
            $this->errors[] = 'Unknown Exception in getPageDefinition()';
            $this->errors[] = $e->getMessage();
        }

        return null;
    }
191764
public function writelnJson($jsonString)
    {
        $keyColor = preg_replace('/"(\w+)": /', '<info>$1</info>: ', $jsonString);
        $valColor = preg_replace('/"([^"]+)"/', "<fg=cyan>'$1'</fg=cyan>", $keyColor);

        $this->output->writeln(stripslashes($valColor));
    }
276811
public function handleJSONRequest( $jsonString ) {
		//Decode JSON string
		$jsonArray = json_decode($jsonString,true);
		if (!$jsonArray) return $this->resp(null,null,-32700,'Cannot Parse JSON');
		if (!isset($jsonArray['jsonrpc'])) return $this->resp(null,null,-32600,'No RPC version');
		if (($jsonArray['jsonrpc']!='2.0')) return $this->resp(null,null,-32600,'Incompatible RPC Version');
		//DO we have an ID to identify this request?
		if (!isset($jsonArray['id'])) return $this->resp(null,null,-32600,'No ID');
		//Fetch the request Identification String.
		$id = $jsonArray['id'];
		//Do we have a method?
		if (!isset($jsonArray['method'])) return $this->resp(null,$id,-32600,'No method');
		//Do we have params?
		if (!isset($jsonArray['params'])) {
			$data = array();
		}
		else {
			$data = $jsonArray['params'];
		}
		//Check method signature
		$method = explode(':',trim($jsonArray['method']));
		if (count($method)!=2) {
			return $this->resp(null, $id, -32600,'Invalid method signature. Use: BEAN:ACTION');
		}
		//Collect Bean and Action
		$beanType = $method[0];
		$action = $method[1];
		//May not contain anything other than ALPHA NUMERIC chars and _
		if (preg_match('/\W/',$beanType)) return $this->resp(null, $id, -32600,'Invalid Bean Type String');
		if (preg_match('/\W/',$action)) return $this->resp(null, $id, -32600,'Invalid Action String');

		try {
			switch($action) {
				case 'store':
					if (!isset($data[0])) return $this->resp(null, $id, -32602,'First param needs to be Bean Object');
					$data = $data[0];
					if (!isset($data['id'])) $bean = RedBean_Facade::dispense($beanType); else
						$bean = RedBean_Facade::load($beanType,$data['id']);
					$bean->import( $data );
					$rid = RedBean_Facade::store($bean);
					return $this->resp($rid, $id);
				case 'load':
					if (!isset($data[0])) return $this->resp(null, $id, -32602,'First param needs to be Bean ID');
					$bean = RedBean_Facade::load($beanType,$data[0]);
					return $this->resp($bean->export(),$id);
				case 'trash':
					if (!isset($data[0])) return $this->resp(null, $id, -32602,'First param needs to be Bean ID');
					$bean = RedBean_Facade::load($beanType,$data[0]);
					RedBean_Facade::trash($bean);
					return $this->resp('OK',$id);
				case 'export':
					if (!isset($data[0])) return $this->resp(null, $id, -32602,'First param needs to be Bean ID');
					$bean = RedBean_Facade::load($beanType,$data[0]);
					$array = RedBean_Facade::exportAll(array($bean),true);
					return $this->resp($array,$id);
				default:
					$modelName = $this->modelHelper->getModelName( $beanType );
					if (!class_exists($modelName)) return $this->resp(null, $id, -32601,'No such bean in the can!');
					$beanModel = new $modelName;
					if (!method_exists($beanModel,$action)) return $this->resp(null, $id, -32601,"Method not found in Bean: $beanType ");
					return $this->resp( call_user_func_array(array($beanModel,$action), $data), $id);
			}
		}
		catch(Exception $exception) {
			return $this->resp(null, $id, -32099,$exception->getCode().'-'.$exception->getMessage());
		}
	}
111328
public function loadJSONString($jsonString)
    {
        $jsonData = json_decode($jsonString);
        foreach ($jsonData as $key => $values) {
            switch ($key) {
                case 'require':
                    foreach ($values as $require => $version) {
                        $this->addRequire($require, $version);
                    }
                    break;
                case 'require-dev':
                    foreach ($values as $require => $version) {
                        $this->addRequireDev($require, $version);
                    }
                    break;
                case 'conflict':
                    foreach ($values as $conflict => $version) {
                        $this->addConflict($conflict, $version);
                    }
                    break;
                case 'replace':
                    foreach ($values as $replace => $version) {
                        $this->addReplace($replace, $version);
                    }
                    break;
                case 'provide':
                    foreach ($values as $provide => $version) {
                        $this->addProvide($provide, $version);
                    }
                    break;
                case 'suggest':
                    foreach ($values as $suggest => $version) {
                        $this->addSuggest($suggest, $version);
                    }
                    break;
                case 'repositories':
                    foreach ($values as $value) {
                        $repository = new Repository();
                        $repository->loadJSONObject($value);
                        $this->addRepository($repository);
                    }
                    break;
                case 'scripts':
                    foreach ($values as $name => $path) {
                        if (is_array($path)) {
                            foreach ($path as $value) {
                                $this->addScript($name, $value);
                            }
                        } else {
                            $this->addScript($name, $path);
                        }
                    }
                    break;
                case 'extra':
                    $this->setExtra($values);
                    break;
                case 'config':
                    $this->setConfig($values);
                    break;
                case 'authors':
                    $this->setAuthors($values);
                    break;
                case 'name':
                    $this->setName($values);
                    break;
                case 'description':
                    $this->setDescription($values);
                    break;
                case 'type':
                    $this->setType($values);
                    break;
                case 'keywords':
                    foreach ($values as $value) {
                        $this->addKeyword($value);
                    }
                    break;
                case 'homepage':
                    $this->setHomepage($values);
                    break;
                case 'readme':
                    $this->setReadme($values);
                    break;
                case 'time':
                    $this->setTime($values);
                    break;
                case 'license':
                    $this->setLicense($values);
                    break;
                case 'support':
                    $this->getSupport()->loadJSONObject($values);
                    break;
                case 'autoload':
                    $this->getAutoload()->loadJSONObject($values);
                    break;
                case 'autoload-dev':
                    $this->getAutoloadDev()->loadJSONObject($values);
                    break;
                case 'minimum-stability':
                    $this->setMinimumStability($values);
                    break;
                case 'version':
                    $this->setVersion($values);
                    break;
            }
        }

        return $this;
    }
745411
public static function fromJSONLDEvent($eventString)
    {
        $event = json_decode($eventString);
        foreach ($event->terms as $term) {
            if ($term->domain == self::DOMAIN) {
                return new self($term->id, $term->label);
            }
        }
        return null;
    }
418418
protected static function getSentencesFromJSON($json)
    {
        $sentencesArray = json_decode($json, true);
        $sentences = "";

        foreach ($sentencesArray["sentences"] as $s) {
            $sentences .= isset($s["trans"]) ? $s["trans"] : '';
        }

        return $sentences;
    }
1198510
public static function jsonValidate($jsonString, $asArray)
    {
        $json = json_decode($jsonString, $asArray);

        if (json_last_error() != JSON_ERROR_NONE) {
            throw new InvalidJsonException(json_last_error_msg(), json_last_error());
        }

        return $json;
    }
986295
private function getArray($json) : array
    {
        $data = json_decode($json, true);
        if ($error = json_last_error() !== JSON_ERROR_NONE) {
            throw new RuntimeException(json_last_error_msg());
        }

        return $data;
    }
42675
private function normalize($jsonString)
    {
        if (!is_string($jsonString)) {
            throw new \InvalidArgumentException(sprintf(
                'Expected a string, got "%s"',
                gettype($jsonString)
            ));
        }
        $chars = str_split($jsonString);
        $inRight = $inQuote = $inFakeQuote = false;
        $fakeQuoteStart = null;

        if (empty($chars)) {
            return;
        }

        if ($chars[0] !== '{') {
            array_unshift($chars, '{');
            $chars[] = '}';
        }

        for ($index = 0; $index < count($chars); $index++) {
            $char = $chars[$index];
            $prevChar = isset($chars[$index - 1]) ? $chars[$index - 1] : null;

            if (!$inQuote && $prevChar == ':') {
                $inRight = true;
            }

            if (!$inQuote && preg_match('{\{,}', $char)) {
                $inRight = false;
            }

            // detect start of unquoted string
            if (!$inQuote && preg_match('{[\$a-zA-Z0-9]}', $char)) {
                array_splice($chars, $index, 0, '"');
                $fakeQuoteStart = $index;
                $index++;
                $inQuote = $inFakeQuote = true;

                continue;
            }

            // if we added a "fake" quote, look for the end of the unquoted string
            if ($inFakeQuote && preg_match('{[\s:\}\],]}', $char)) {

                // if we are on the left side, then "]" is OK.
                if (!$inRight && $char === ']') {
                    continue;
                }

                if ($inRight) {

                    // extract the right hand value
                    $string = implode('', array_slice($chars, $fakeQuoteStart + 1, $index - 1 - $fakeQuoteStart));

                    // if it is a number, then we don't quote it
                    if (is_numeric($string)) {
                        unset($chars[$fakeQuoteStart]);
                        $chars = array_values($chars);
                        $inQuote = $inFakeQuote = false;
                        $index--;

                        continue;
                    }

                    // if it is a boolean, then we don't quote it
                    if (in_array($string, ['true', 'false'])) {
                        unset($chars[$fakeQuoteStart]);
                        $chars = array_values($chars);
                        $inQuote = $inFakeQuote = false;
                        $index--;

                        continue;
                    }
                }

                // add the ending quote
                array_splice($chars, $index, 0, '"');
                $index++;
                $inQuote = $inFakeQuote = false;

                continue;
            }

            // enter standard quote mode
            if (!$inQuote && $char === '"') {
                $inQuote = true;

                continue;
            }

            // if we are in quote mode and encounter a closing quote, and the last character
            // was not the escape character
            if ($inQuote && $char === '"' && $prevChar !== '\\') {
                $inQuote = $inFakeQuote = false;

                continue;
            }
        }

        // if we were in a fake quote and hit the end, then add the closing quote
        if ($inFakeQuote) {
            $chars[] = '"';
        }

        $normalized = implode('', $chars);

        return $normalized;
    }
486962
public static function jsonToArray(string $string): array
    {
        static $jsonErrors = [
            JSON_ERROR_DEPTH => 'JSON_ERROR_DEPTH - Maximum stack depth exceeded',
            JSON_ERROR_STATE_MISMATCH => 'JSON_ERROR_STATE_MISMATCH - Underflow or the modes mismatch',
            JSON_ERROR_CTRL_CHAR => 'JSON_ERROR_CTRL_CHAR - Unexpected control character found',
            JSON_ERROR_SYNTAX => 'JSON_ERROR_SYNTAX - Syntax error, malformed JSON',
            JSON_ERROR_UTF8 => 'JSON_ERROR_UTF8 - Malformed UTF-8 characters, possibly incorrectly encoded',
        ];

        $data = json_decode($string, true);

        if (JSON_ERROR_NONE !== json_last_error()) {
            $last = json_last_error();

            throw new \RuntimeException(
                'Unable to parse JSON data: '
                .(isset($jsonErrors[$last]) ? $jsonErrors[$last] : 'Unknown error')
            );
        }

        return $data;
    }
813884
function jsonSerialize(): \stdClass {
    return (object) [
      'found' => $this->getFound(),
      'hit' => $this->getHit(),
      'data' => array_map(function(LineData $item) {
        return $item->jsonSerialize();
      }, $this->getData()->getArrayCopy())
    ];
  }