main/core/Twig/SerializerExtension.php
public function serialize($data, $group = null)
    {
        $context = new SerializationContext();

        if ($group) {
            $context->setGroups($group);
        }

        return $this->serializer->serialize($data, 'json', $context);
    }
public function serialize($data, $group = null)
    {
        $context = new SerializationContext();

        if ($group) {
            $context->setGroups($group);
        }

        return $this->serializer->serialize($data, 'json', $context);
    }
public function serialize ( $ data , $ group = null ) { $ context = new SerializationContext ( ) ; if ( $ group ) { $ context -> setGroups ( $ group ) ; } return $ this -> serializer -> serialize ( $ data , 'json' , $ context ) ; }
Serializes data to JSON, optionally filtering on a serialization group.

@param mixed  $data
@param string $group

@deprecated serialization should be handled by SerializerProvider
Serializes data to JSON optionally filtering on a serialization group .