Serializer/Job/SerializationHelper.php
public function serializeParameters($type, array $parameters)
    {
        $jobType = $this->registry->get($type);
        $indices = $jobType->getIndicesOfSerializableParameters();
        if (count($indices) < count($parameters)) {
            throw new \InvalidArgumentException(sprintf('More parameters provided for serialization than defined for job "%s"', $type));
        }

        $i = 0;
        $serializedParameters = array();
        foreach ($parameters as $parameter) {
            if (null == $parameter) {
                $serializedParameters[] = null;
            } else {
                $serializedParameters[] = $this->serializer->serialize($parameter, 'json', $this->getParamSerializationContext($jobType, $indices[$i]));
            }
            $i++;
        }

        $data = json_encode($serializedParameters);
        if (false === $data) {
            throw new \RuntimeException(sprintf('Serialization failed with error "%s"', json_last_error_msg()));
        }

        return $data;
    }
public function serializeParameters($type, array $parameters)
    {
        $jobType = $this->registry->get($type);
        $indices = $jobType->getIndicesOfSerializableParameters();
        if (count($indices) < count($parameters)) {
            throw new \InvalidArgumentException(sprintf('More parameters provided for serialization than defined for job "%s"', $type));
        }

        $i = 0;
        $serializedParameters = array();
        foreach ($parameters as $parameter) {
            if (null == $parameter) {
                $serializedParameters[] = null;
            } else {
                $serializedParameters[] = $this->serializer->serialize($parameter, 'json', $this->getParamSerializationContext($jobType, $indices[$i]));
            }
            $i++;
        }

        $data = json_encode($serializedParameters);
        if (false === $data) {
            throw new \RuntimeException(sprintf('Serialization failed with error "%s"', json_last_error_msg()));
        }

        return $data;
    }
Serializes the parameters of a job.

@param string $type The job type
@param array  $parameters
@return string