File tree Expand file tree Collapse file tree
src/main/de/interaapps/jsonplus Expand file tree Collapse file tree Original file line number Diff line number Diff 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 );
You can’t perform that action at this time.
0 commit comments