Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Mashape committed Feb 4, 2011
1 parent 30ee484 commit 245a23f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions mashape/methods/call/helpers/serializeObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ function serializeObject($result, $instance, $isSimpleResult, $serverKey) {
$fieldValue = $reflectedClass->getMethod($fieldMethod)->invoke($result);
}

if ($fieldValue == null && $field->isOptional()) {
if ($fieldValue === null && $field->isOptional()) {
// Don't serialize the field
continue;
}

$json .= '"' . $fieldName . '":';
if ($fieldValue == null) {
if ($fieldValue === null) {
$json .= JsonUtils::encodeToJson($fieldValue);
} else {

Expand All @@ -107,7 +107,9 @@ function serializeObject($result, $instance, $isSimpleResult, $serverKey) {
}
$json .= ",";
}
$json = JsonUtils::removeLastChar($fields, $json);
if (substr($json, strlen($json) - 1, 1) != "{") {
$json = JsonUtils::removeLastChar($fields, $json);
}
// Close element
$json .= "}";
}
Expand Down

0 comments on commit 245a23f

Please sign in to comment.