-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
27 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* An interface for any object that can be represented in JSON notation. The class | ||
* follows the specifications found at https://www.json.org/index.html. | ||
* @author Ibrahim <[email protected]> | ||
* @since 1.1 | ||
* @since 1.2 | ||
*/ | ||
class JsonX { | ||
/** | ||
|
@@ -176,32 +176,37 @@ private function parseArray($value){ | |
else{ | ||
$comma = ', '; | ||
} | ||
$valueType = gettype($value[$x]); | ||
if($valueType == 'integr' || $valueType == 'double'){ | ||
if(is_nan($value[$x])){ | ||
$arr .= '"NAN"'.$comma; | ||
} | ||
else if($value[$x] == INF){ | ||
$arr .= '"INF"'.$comma; | ||
if($value[$x] instanceof JsonI){ | ||
$arr .= $value[$x]->toJSON().$comma; | ||
} | ||
else{ | ||
$valueType = gettype($value[$x]); | ||
if($valueType == 'integr' || $valueType == 'double'){ | ||
if(is_nan($value[$x])){ | ||
$arr .= '"NAN"'.$comma; | ||
} | ||
else if($value[$x] == INF){ | ||
$arr .= '"INF"'.$comma; | ||
} | ||
else{ | ||
$arr .= $value[$x].$comma; | ||
} | ||
} | ||
else{ | ||
$arr .= $value[$x].$comma; | ||
else if($valueType == 'string'){ | ||
$arr .= '"'.JsonX::escapeJSONSpecialChars($value[$x]).'"'.$comma; | ||
} | ||
} | ||
else if($valueType == 'string'){ | ||
$arr .= '"'.JsonX::escapeJSONSpecialChars($value[$x]).'"'.$comma; | ||
} | ||
else if($valueType == 'boolean'){ | ||
if($value[$x] == TRUE){ | ||
$arr .= 'true'.$comma; | ||
else if($valueType == 'boolean'){ | ||
if($value[$x] == TRUE){ | ||
$arr .= 'true'.$comma; | ||
} | ||
else{ | ||
$arr .= 'false'.$comma; | ||
} | ||
} | ||
else{ | ||
$arr .= 'false'.$comma; | ||
else if($valueType == 'array'){ | ||
$arr .= $this->parseArray($value[$x]); | ||
} | ||
} | ||
else if($valueType == 'array'){ | ||
$arr .= $this->parseArray($value[$x]); | ||
} | ||
} | ||
$arr.= ']'; | ||
return $arr; | ||
|