diff --git a/adapters/cisco_nx_rest/me_connect.php b/adapters/cisco_nx_rest/me_connect.php
index a919e384..f581686c 100755
--- a/adapters/cisco_nx_rest/me_connect.php
+++ b/adapters/cisco_nx_rest/me_connect.php
@@ -165,24 +165,17 @@ protected function execute_curl_command($origin, $rest_cmd, $curl_cmd, $payload_
}
$xml;
$result = preg_replace('/xmlns="[^"]+"/', '', $result);
- if (strpos($curl_cmd, "Content-Type: application/json")) {
- $result=preg_replace('/":([0-9]+)\.([0-9]+)/', '":"$1.$2"', $result);
+ //test if result is a json content or not
+ $json_candidate = preg_replace('/":([0-9]+)\.([0-9]+)/', '":"$1.$2"', $result);
+ json_decode($json_candidate);
+ if (json_last_error() === JSON_ERROR_NONE ) {
+ $result = $json_candidate;
$array = json_decode ( $result, true );
if (isset ( $array ['sid'] )) {
$this->key = $array ['sid'];
}
-
// call array to xml conversion function
$xml = arrayToXml ( $array, '' );
- }
- elseif (strpos($curl_cmd, "content-type:application/json-rpc")) {
- $result=preg_replace('/":([0-9]+)\.([0-9]+)/', '":"$1.$2"', $result);
- $array = json_decode ( $result, true );
- if (isset ( $array ['sid'] )) {
- $this->key = $array ['sid'];
- }
- // call array to xml conversion function
- $xml = arrayToXml ($array, '');
} else {
if (empty(trim($result))) {
$result="";