diff --git a/jsonrpc_client.module b/jsonrpc_client.module
index b201ce6..fa0d7e1 100644
--- a/jsonrpc_client.module
+++ b/jsonrpc_client.module
@@ -40,10 +40,9 @@ class JsonRpcClient {
     $json_message = $this->json_string($method, $params, $sessid);
     $this->_debug($json_message);
     $http_result = drupal_http_request(
-        $this->url,array('Content-Type' => 'application/json'),
-        'POST',
-        $json_message
-      );
+      $this->url,
+	  array('headers' => array ('Content-Type' => 'application/json'), 'method' => 'POST', 'data' => $json_message)
+    );
     $this->_debug($http_result);
     // check for HTTP error
     if ($http_result->code != '200') {
@@ -52,7 +51,7 @@ class JsonRpcClient {
           array('@code' => $http_result->code, '@message' => $http_result->error))
       );
     }
-    $result = json_decode($http_result->data, TRUE);
+    $result = drupal_json_decode($http_result->data, TRUE);
     // check for mismatched JSON id
     if ($result['id'] != $this->id) {
       throw new JsonRpcClientHttpException(
@@ -111,7 +110,7 @@ class JsonRpcClient {
     }
     $message['id'] = $this->id;
     //convert to a JSON string
-    $json_message = drupal_to_js($message);
+    $json_message = drupal_json_encode($message);
     return $json_message;
   }
   
