# media-cloud-sync/1.4.2/includes/sdk/s3/Aws/Api/Serializer/RestJsonSerializer.php

Media Cloud Sync, version 1.4.2. 36 lines.

- Page: https://pluginprobe.com/plugins/media-cloud-sync/1.4.2/code/includes/sdk/s3/Aws/Api/Serializer/RestJsonSerializer.php
- Raw: https://pluginprobe.com/plugins/media-cloud-sync/1.4.2/raw/includes/sdk/s3/Aws/Api/Serializer/RestJsonSerializer.php
- Modified: 2026-05-10T10:14:36+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/media-cloud-sync/1.4.2/code/includes/sdk/s3/Aws/Api/Serializer/RestJsonSerializer.php#L10-L20`.

```php
<?php

namespace Dudlewebs\WPMCS\s3\Aws\Api\Serializer;

use Dudlewebs\WPMCS\s3\Aws\Api\Service;
use Dudlewebs\WPMCS\s3\Aws\Api\StructureShape;
/**
 * Serializes requests for the REST-JSON protocol.
 * @internal
 */
class RestJsonSerializer extends RestSerializer
{
    /** @var JsonBody */
    private $jsonFormatter;
    /** @var string */
    private $contentType;
    /**
     * @param Service  $api           Service API description
     * @param string   $endpoint      Endpoint to connect to
     * @param JsonBody $jsonFormatter Optional JSON formatter to use
     */
    public function __construct(Service $api, $endpoint, ?JsonBody $jsonFormatter = null)
    {
        parent::__construct($api, $endpoint);
        $this->contentType = JsonBody::getContentType($api);
        $this->jsonFormatter = $jsonFormatter ?: new JsonBody($api);
    }
    protected function payload(StructureShape $member, array|string $value, array &$opts)
    {
        $opts['headers']['Content-Type'] = $this->contentType;
        $body = $this->jsonFormatter->build($member, $value);
        $opts['headers']['Content-Length'] = \strlen($body);
        $opts['body'] = $body;
    }
}

```
