Skip to content

Commit 60ad5c7

Browse files
committed
Initial
1 parent 17e2cbd commit 60ad5c7

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/main/de/interaapps/jsonplus/JSONPlus.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ public function fromJson($json, $type=null){
3737
}
3838

3939
public function map($o, $type = null){
40-
if ($type == null)
41-
$type = get_class($o);
40+
if ($type == null) {
41+
$type = gettype($o);
42+
if ($type == "object")
43+
$type = get_class($type);
44+
}
4245

4346
foreach ($this->typeMapper as $typeName => $typeMapper) {
4447
if ($type == $typeName)
@@ -52,8 +55,11 @@ public function toJson($o, $type = null) : string {
5255
}
5356

5457
public function mapToJson($o, $type = null){
55-
if ($type == null)
56-
$type = get_class($o);
58+
if ($type == null) {
59+
$type = gettype($o);
60+
if ($type == "object")
61+
$type = get_class($type);
62+
}
5763
foreach ($this->typeMapper as $typeName => $typeMapper) {
5864
if ($type == $typeName)
5965
return $typeMapper->mapToJson($o, $type);

0 commit comments

Comments
 (0)