Makes data decoded from JSON application/x-www-form-encoded compliant.

@param array $data
432927
private function xWwwFormEncodedLike(&$data)
    {
        foreach ($data as $key => &$value) {
            if (is_array($value)) {
                // Encode recursively
                $this->xWwwFormEncodedLike($value);
            } elseif (false === $value) {
                // Checkbox-like behavior removes false data but PATCH HTTP method with just checkboxes does not work
                // To fix this issue we prefer transform false data to null
                // See https://github.com/FriendsOfSymfony/FOSRestBundle/pull/883
                $value = null;
            } elseif (!is_string($value)) {
                // Convert everything to string
                // true values will be converted to '1', this is the default checkbox behavior
                $value = strval($value);
            }
        }
    }
1073125
public function encode(array $data): string
    {
        $options = JSON_PRESERVE_ZERO_FRACTION | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES;
        if ($this->prettyPrint) {
            $options = $options | JSON_PRETTY_PRINT;
        }

        return json_encode($data, $options);
    }
863520
public function sendData($data)
    {
        $method = $this->getRequestMethod();
        $url    = $this->getRequestUrl($data);
        $body   = $this->getRequestBody();

        $headers = [
            'Content-Type' => 'application/x-www-form-urlencoded'
        ];

        $response = $this->httpClient->request($method, $url, $headers, $body);

        $payload = $this->decode($response->getBody());

        return $payload;
    }
245339
public static function arr2json($data)
    {
        $json = json_encode(self::buildEnEmojiData($data), JSON_UNESCAPED_UNICODE);
        return $json === '[]' ? '{}' : $json;
    }
522502
private function safe_decode($data) {
    if (is_array($data)) {
      return array_map(array($this, 'safe_decode'), $data);
    } else if (is_scalar($data)) {
      return rawurldecode($data);
    } else {
      return '';
    }
  }
1161409
public function decode($data)
    {
        if (is_string($data)) {
            $this->arrayData = json_decode($data, true); // true gives us associative arrays
        }

        if (!is_string($data) || !$this->isValidJson()) {
            throw new JsonDecodingFailedException('The data provided was not proper JSON');
        }

        return $this->arrayData;
    }
234009
private function parseData(array $data)
    {
        $this->type = array_get($data, 'data.type');
        $this->id = array_get($data, 'data.id');

        $this->attributes = array_get($data, 'data.attributes');

        $this->version = array_get($data, 'jsonapi.version', $this->version);

        $this->meta = array_get($data, 'meta');
    }
545646
private function encodeDict(array $data = null)
    {
        $data = is_null($data) ? $this->data : $data;
        ksort($data); // bencode spec requires dicts to be sorted alphabetically

        $dict = "";
        foreach ($data as $key => $value) {
            $dict .= $this->encodeString($key) . $this->doEncode($value);
        }

        return "d{$dict}e";
    }
61301
public function decode($data)
    {
        $int = (int) ($decoded = parent::decode($data));

        return (string) $int === $decoded ? $int : 0;
    }
178140
private function decode($data)
	{
		return function_exists('json_decode') ? json_decode($data, true) : CJSON::decode($data, true);
	}
135666
protected function decodeJson($data) {
        if (strpos($data, 'callback') !== false) {
            $leftPos = strpos($data, '(');
            $rightPos = strrpos($data, ')');
            $data = substr($data, $leftPos + 1, $rightPos - $leftPos -1);
        }
        return Json::decode($data);
    }
600980
protected function jsonEncode(array $data)
    {
        set_error_handler(function () {
            $this->handleJsonError(JSON_ERROR_SYNTAX);
        }, E_WARNING);
        
        $json = json_encode($data, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
        restore_error_handler();
        $this->handleJsonError(json_last_error());
        
        return $json;
    }
912424
public function jsonResponse($data = [])
	{
		global $db_show_debug;

		$json = '';
		$result = false;

		// Defensive programming anyone?
		if (empty($data))
			return false;

		// This is pretty simply, just encode the supplied data and be done with it.
		$json = json_encode($data);

		$result = json_last_error() == JSON_ERROR_NONE;

		if ($result)
		{
			// Don't need extra stuff...
			$db_show_debug = false;

			// Kill anything else
			ob_end_clean();

			if ($this->_app->modSetting('CompressedOutput'))
				@ob_start('ob_gzhandler');

			else
				ob_start();

			// Set the header.
			header('Content-Type: application/json');

			// Echo!
			echo $json;

			// Done
			obExit(false);
		}

		return $result;
	}
998043
private function preparePostData(array &$data) {
        foreach ($data as $key => &$val) {
            if (is_string($val) && $val{0} == '@' && is_file(trim(substr($val, 1), '"'))) {
                $data [ $key ] = new \CURLFile(realpath(trim(substr($val, 1), '"')));
            } else if (is_array($val)) {
                $this->preparePostData($val);
            }
        }
    }
104478
protected function cleanFormData(array $data)
    {
        foreach ($data as $key => $value) {
            if (\is_array($value)) {
                $data[$key] = $this->cleanFormData($value);
            } elseif (\is_object($value)) {
                unset($data[$key]);
            }
        }

        return $data;
    }
584300
public static function decode($data)
    {
        if (!is_string($data)) {
            throw new InvalidArgumentException('data must be string');
        }

        // undo the URL safe replacement
        $convertedData = strtr($data, '-_', '+/');

        // restore the padding
        switch (strlen($convertedData) % 4) {
            case 0:
                break;
            case 2:
                $convertedData .= '==';
                break;
            case 3:
                $convertedData .= '=';
                break;
            default:
                throw new InvalidArgumentException('invalid base64url string length');
        }

        return parent::decode($convertedData);
    }
1297418
public static function encodePhpSerialize( array $data ) {
		try {
			return serialize( $data );
		} catch ( \Exception $ex ) {
			self::$logger->error( 'PHP serialization failed: ' . $ex->getMessage() );
			return null;
		}
	}