public function mapArray($json, $array, $class = null, $parent_key = '')
    {
        foreach ($json as $key => $jvalue) {
            if ($class === null) {
                $array[$key] = $jvalue;
            } else if ($this->isArrayOfType($class)) {
                $array[$key] = $this->mapArray(
                    $jvalue,
                    array(),
                    substr($class, 0, -2)
                );
            } else if ($this->isFlatType(gettype($jvalue))) {
                //use constructor parameter if we have a class
                // but only a flat type (i.e. string, int)
                if ($jvalue === null) {
                    $array[$key] = null;
                } else {
                    if ($this->isSimpleType($class)) {
                        settype($jvalue, $class);
                        $array[$key] = $jvalue;
                    } else {
                        $array[$key] = $this->createInstance(
                            $class, true, $jvalue
                        );
                    }
                }
            } else if ($this->isFlatType($class)) {
                throw new JsonMapper_Exception(
                    'JSON property "' . ($parent_key ? $parent_key : '?') . '"'
                    . ' is an array of type "' . $class . '"'
                    . ' but contained a value of type'
                    . ' "' . gettype($jvalue) . '"'
                );
            } else if (is_a($class, 'ArrayObject', true)) {
                $array[$key] = $this->mapArray(
                    $jvalue,
                    $this->createInstance($class)
                );
            } else {
                $array[$key] = $this->map(
                    $jvalue, $this->createInstance($class, false, $jvalue)
                );
            }
        }
        return $array;
    }
public function mapArray($json, $array, $class = null, $parent_key = '')
    {
        foreach ($json as $key => $jvalue) {
            if ($class === null) {
                $array[$key] = $jvalue;
            } else if ($this->isArrayOfType($class)) {
                $array[$key] = $this->mapArray(
                    $jvalue,
                    array(),
                    substr($class, 0, -2)
                );
            } else if ($this->isFlatType(gettype($jvalue))) {
                //use constructor parameter if we have a class
                // but only a flat type (i.e. string, int)
                if ($jvalue === null) {
                    $array[$key] = null;
                } else {
                    if ($this->isSimpleType($class)) {
                        settype($jvalue, $class);
                        $array[$key] = $jvalue;
                    } else {
                        $array[$key] = $this->createInstance(
                            $class, true, $jvalue
                        );
                    }
                }
            } else if ($this->isFlatType($class)) {
                throw new JsonMapper_Exception(
                    'JSON property "' . ($parent_key ? $parent_key : '?') . '"'
                    . ' is an array of type "' . $class . '"'
                    . ' but contained a value of type'
                    . ' "' . gettype($jvalue) . '"'
                );
            } else if (is_a($class, 'ArrayObject', true)) {
                $array[$key] = $this->mapArray(
                    $jvalue,
                    $this->createInstance($class)
                );
            } else {
                $array[$key] = $this->map(
                    $jvalue, $this->createInstance($class, false, $jvalue)
                );
            }
        }
        return $array;
    }
public function mapArray ( $ json , $ array , $ class = null , $ parent_key = '' ) { foreach ( $ json as $ key => $ jvalue ) { if ( $ class === null ) { $ array [ $ key ] = $ jvalue ; } else if ( $ this -> isArrayOfType ( $ class ) ) { $ array [ $ key ] = $ this -> mapArray ( $ jvalue , array ( ) , substr ( $ class , 0 , - 2 ) ) ; } else if ( $ this -> isFlatType ( gettype ( $ jvalue ) ) ) { //use constructor parameter if we have a class // but only a flat type (i.e. string, int) if ( $ jvalue === null ) { $ array [ $ key ] = null ; } else { if ( $ this -> isSimpleType ( $ class ) ) { settype ( $ jvalue , $ class ) ; $ array [ $ key ] = $ jvalue ; } else { $ array [ $ key ] = $ this -> createInstance ( $ class , true , $ jvalue ) ; } } } else if ( $ this -> isFlatType ( $ class ) ) { throw new JsonMapper_Exception ( 'JSON property "' . ( $ parent_key ? $ parent_key : '?' ) . '"' . ' is an array of type "' . $ class . '"' . ' but contained a value of type' . ' "' . gettype ( $ jvalue ) . '"' ) ; } else if ( is_a ( $ class , 'ArrayObject' , true ) ) { $ array [ $ key ] = $ this -> mapArray ( $ jvalue , $ this -> createInstance ( $ class ) ) ; } else { $ array [ $ key ] = $ this -> map ( $ jvalue , $ this -> createInstance ( $ class , false , $ jvalue ) ) ; } } return $ array ; }
Map an array

@param array  $json       JSON array structure from json_decode()
@param mixed  $array      Array or ArrayObject that gets filled with
data from $json
@param string $class      Class name for children objects.
All children will get mapped onto this type.
Supports class names and simple types
like "string" and nullability "string|null".
Pass "null" to not convert any values
@param string $parent_key Defines the key this array belongs to
in order to aid debugging.

@return mixed Mapped $array is returned
Map an array