src/Query/Parser.php
public static function singleDocument($document)
    {
        if (gettype($document)!="array" && gettype($document)!="object") {
            throw new ClusterpointException("\"->insert()\" function: parametr passed ".json_encode(self::escape_string($document))." is not in valid document format.", 9002);
        }
        $query = "{";
        $first = true;
        foreach ($document as $key => $value) {
            if (!$first) {
                $query .= ",";
            }
            $query .= '"'.self::escape_string($key).'" : '.json_encode($value);
            $first = false;
        }
        $query .= '}';
        return $query;
    }
public static function singleDocument($document)
    {
        if (gettype($document)!="array" && gettype($document)!="object") {
            throw new ClusterpointException("\"->insert()\" function: parametr passed ".json_encode(self::escape_string($document))." is not in valid document format.", 9002);
        }
        $query = "{";
        $first = true;
        foreach ($document as $key => $value) {
            if (!$first) {
                $query .= ",";
            }
            $query .= '"'.self::escape_string($key).'" : '.json_encode($value);
            $first = false;
        }
        $query .= '}';
        return $query;
    }
Encode single document in valid format.

@param  mixed $document
@return string