--- json_server.original.module	2010-05-04 13:00:36.000000000 -0700
+++ json_server.module	2010-09-09 16:12:24.000000000 -0700
@@ -23,7 +23,7 @@ function json_server_server_info() {
  *  Implementation of hook_server_error().
  */
 function json_server_server_error($message) {
-  return array("#error" => TRUE, "#message" => $message);
+  return array("error" => TRUE, "message" => $message);
 }
 
 
@@ -32,7 +32,7 @@ function json_server_server_error($messa
  */
 function json_server_server() {
 if (!isset($_POST)) {
-  return drupal_to_js(array('#error' => TRUE, '#data' => "JSON server accepts POST requests only."));
+  return json_encode(array('#error' => TRUE, '#data' => "JSON server accepts POST requests only."));
 }
   
   $methods = services_get_all();
@@ -47,10 +47,15 @@ if (!isset($_POST)) {
       $args = array();
       foreach($method['args'] as $arg) {
         if(isset($_POST[$arg['name']])) {
-          $args[] = drupal_parse_json($_POST[$arg['name']]);
+          if (is_array($_POST[$arg['name']])) {
+            $args[] = $_POST[$arg['name']];
+          }
+          else {
+            $args[] = drupal_parse_json($_POST[$arg['name']]);
+          }
         }
         elseif($arg['optional'] == 0) {
-          return drupal_to_js(array("#error" => TRUE, "#data" => "Argument ". $arg['name'] ." not recieved"));
+          return json_encode(array("#error" => TRUE, "#data" => "Argument ". $arg['name'] ." not recieved"));
         }
         else {
           $args[$arg['name']] = NULL;
@@ -58,13 +63,13 @@ if (!isset($_POST)) {
       }
       $result = services_method_call($method['method'], $args);
       if (is_array($result) && $result['error'] === TRUE)
-        return drupal_to_js(array('#error' => TRUE, '#data' => $result['message']));
+        return json_encode(array('#error' => TRUE, '#data' => $result['message']));
       
-      return drupal_to_js(array('#error' => FALSE, '#data' => $result));
+      return json_encode(array('#error' => FALSE, '#data' => $result));
     }
   }
 
-  return drupal_to_js(array('#error' => TRUE, '#data' => "Invalid method $request"));
+  return json_encode(array('#error' => TRUE, '#data' => "Invalid method $request"));
 }
       
 
