src/Graviton/RestBundle/Service/RestUtils.php
public function serialize($result)
    {
        try {
            // array is serialized as an object {"0":{...},"1":{...},...} when data contains an empty objects
            // we serialize each item because we can assume this bug affects only root array element
            if (is_array($result) && array_keys($result) === range(0, count($result) - 1)) {
                $result = array_map(
                    function ($item) {
                        return $this->serializeContent($item);
                    },
                    $result
                );

                return '['.implode(',', array_filter($result)).']';
            }

            return $this->serializeContent($result);
        } catch (\Exception $e) {
            throw new SerializationException($e);
        }
    }
public function serialize($result)
    {
        try {
            // array is serialized as an object {"0":{...},"1":{...},...} when data contains an empty objects
            // we serialize each item because we can assume this bug affects only root array element
            if (is_array($result) && array_keys($result) === range(0, count($result) - 1)) {
                $result = array_map(
                    function ($item) {
                        return $this->serializeContent($item);
                    },
                    $result
                );

                return '['.implode(',', array_filter($result)).']';
            }

            return $this->serializeContent($result);
        } catch (\Exception $e) {
            throw new SerializationException($e);
        }
    }
public function serialize ( $ result ) { try { // array is serialized as an object {"0":{...},"1":{...},...} when data contains an empty objects // we serialize each item because we can assume this bug affects only root array element if ( is_array ( $ result ) && array_keys ( $ result ) === range ( 0 , count ( $ result ) - 1 ) ) { $ result = array_map ( function ( $ item ) { return $ this -> serializeContent ( $ item ) ; } , $ result ) ; return '[' . implode ( ',' , array_filter ( $ result ) ) . ']' ; } return $ this -> serializeContent ( $ result ) ; } catch ( \ Exception $ e ) { throw new SerializationException ( $ e ) ; } }
Serialize the given record and throw an exception if something went wrong

@param object|object[] $result Record(s)

@throws \Graviton\ExceptionBundle\Exception\SerializationException

@return string $content Json content
Serialize the given record and throw an exception if something went wrong