@param string $body

@return array JSON decoded data

@throws InvalidRequestException
179514
private function decodeJsonBody($body)
    {
        $data = json_decode($body, true);
        if ($data === null) {
            throw new InvalidRequestException('The request JSON body could not be decoded');
        }

        return $data;
    }
196692
public function beforeDeserialize(
        \Magento\Framework\Webapi\Rest\Request\Deserializer\Json $subject,
        $encodedBody
    ) {
        if (strpos($encodedBody, '&form_key=')) {
            $parts = explode('&form_key=', $encodedBody);
            $encodedBody = reset($parts);
        }
        return [$encodedBody];
    }
818767
public function jsonDecode(string $plain): array
    {
        $data = json_decode($plain, true);

        if (json_last_error() != JSON_ERROR_NONE) {
            throw new \RuntimeException(self::$messages[json_last_error()]);
        }

        return $data;
    }
540145
public function decode(string $json): array
    {
        $decoded = \json_decode($json, true);
        if (\json_last_error() !== JSON_ERROR_NONE) {
            throw new DecodingException(\json_last_error_msg(), \json_last_error());
        }
        return $decoded;
    }
969880
public function jsonDecode()
    {
        $json = json_decode($this->body, true);
        if ($json===null){
            throw new JsonFormatException($this->body);
        }
        return $json;
    }
705207
protected function extractRequestBody()
    {
        $propertyMappingConfiguration = new PropertyMappingConfiguration();
        $propertyMappingConfiguration->setTypeConverter($this->objectManager->get(MediaTypeConverterInterface::class));
        $propertyMappingConfiguration->setTypeConverterOption(MediaTypeConverterInterface::class,
            MediaTypeConverterInterface::CONFIGURATION_MEDIA_TYPE, 'application/json');
        $result = $this->objectManager->get(PropertyMapper::class)->convert($this->request->getHttpRequest()->getContent(),
            'array', $propertyMappingConfiguration);

        return $result['data'];
    }
557937
private function sendPostRequest(array $body)
    {
        $requestBodyKey = version_compare(ClientInterface::VERSION, '6.0', '>=') ? 'form_params' : 'body';
        $response = $this->httpClient->post('', [
            $requestBodyKey => $body,
        ]);

        return \json_decode($response->getBody(), true);
    }
1218801
protected function decodeRequest(Request $request)
    {
        $decodedRequest = json_decode($request->getContent(), true);

        if (null === $decodedRequest) {
            throw new InvalidDataException('Invalid request content sent.', []);
        }

        return $decodedRequest;
    }
885919
private static function fromJsonString($requestBody)
    {
        $data = json_decode($requestBody, true);
        if (JSON_ERROR_NONE !== json_last_error() || !is_array($data)) {
            throw new \RuntimeException('Invalid POST data.');
        }

        return new Message($data);
    }
1273664
public function parse($rawBody, $contentType)
    {
        try {
            return Json::decode($rawBody, $this->asArray);
        } catch (\Exception $e) {
            if ($this->throwException) {
                throw new RequestException('Invalid JSON data in request body: ' . $e->getMessage(), [], $e);
            }

            return null;
        }
    }
7015
public function parseNewLineSeparatedBody($body)
    {
        $data = array();

        if (!$body) {
            return $data;
        }

        $parts = preg_split("/\\r?\\n/", $body);
        foreach ($parts as $str) {
            if (!$str) {
                continue;
            }

            list ($key, $value) = explode('=', $str);
            $data[$key] = $value;
        }

        return $data;
    }
1356439
private static function getJsonPayload($payload)
    {
        $payload = json_decode(base64_decode($payload), true);
        if (! $payload || self::isInvalidPayload($payload)) {
            throw new Exceptions\DecryptionException('The payload is invalid.');
        }

        return $payload;
    }
1161737
protected function parse($body)
    {
        $disableEntities = libxml_disable_entity_loader(true);
        $internalErrors = libxml_use_internal_errors(true);

        try {
            $xml = new SimpleXMLElement((string) $body ?: '<root />', LIBXML_NONET);

            return json_decode(json_encode($xml), true);
        } catch (Exception $e) {
            //
        } catch (Throwable $e) {
            //
        } finally {
            libxml_disable_entity_loader($disableEntities);
            libxml_use_internal_errors($internalErrors);
        }
    }
1373251
protected function parseBody(array $body)
    {
        $jobs = [];
        if (!empty($body)) {
            if (is_string($body[0])) {
                foreach ($body as $element) {
                    $jobs[] = ['id' => $element];
                }
            } else {
                $keyValueResponse = new KeyValueResponse();
                $keyValueResponse->setCommand($this->command);

                foreach ($body as $element) {
                    $keyValueResponse->setBody($element);
                    $jobs[] = $keyValueResponse->parse();
                }
            }
        }
        return ['jobs' => $jobs];
    }
900194
public function getJsonBody() : array
    {
        $json = json_decode($this->getRawBody(), true);

        if ($json === null) {
            throw new RuntimeException('Body could not be decoded as JSON');
        }

        return $json;
    }
37606
protected function httpPostJson($uri, $body)
    {
        $this->log[] = [
                        'request' => [
                                    'method' => 'POST',
                                    'uri'    => $uri,
                                    'body'   => $body,
                                    ],
                        ];
        $response = \Httpful\Request::post($uri)
                                                ->basicAuth($this->username, $this->password)
                                                ->sendsAndExpects(\Httpful\Mime::JSON)
                                                ->parseWith(function ($body) {
                                                   return $body;
                                                   //return \Metaclassing\Utility::decodeJson($body);
                                                })
                                                ->body($body)
                                                ->send()
                                                ->body;
        $this->log[count($this->log) - 1]['response'] = $response;
        //if ($response['success'] != true) {
        //    throw new \Exception("post to {$uri} unsuccessful");
        //}

        return $response;
    }
1017093
private function decodeBody(): void
    {
        if (empty($this->body) || $this->body === null) {
            $this->decodedBody = [];

            return;
        }

        $this->decodedBody = json_decode($this->body, true);

        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new JsonException('The body of the response could not be decoded as JSON.');
        }

        if (!\is_array($this->decodedBody)) {
            $this->decodedBody = [];
        }
    }