Serializer/Serializer.php
public function serialize($data, $format, array $context = array())
    {
        if ('jsonld' !== $format) {
            throw new UnexpectedValueException('Serialization for the format ' . $format . ' is not supported');
        }

        if (false === is_object($data)) {
            throw new \Exception('Only objects can be serialized');
        }

        return JsonLD::toString($this->doSerialize($data, true), true);
    }
public function serialize($data, $format, array $context = array())
    {
        if ('jsonld' !== $format) {
            throw new UnexpectedValueException('Serialization for the format ' . $format . ' is not supported');
        }

        if (false === is_object($data)) {
            throw new \Exception('Only objects can be serialized');
        }

        return JsonLD::toString($this->doSerialize($data, true), true);
    }
Serializes data in the appropriate format

@param mixed  $data    any data
@param string $format  format name
@param array  $context options normalizers/encoders have access to

@return string