private static function parseKeyValue($key, $val, & $pointer) 
    {
        // Flags
        $openQuote = false;
        $openDoubleQuote = false;

        // Buffer
        $buff = '';

        // Parse
        for($i = 0; $i < strlen($key); $i++) {
            // Handle quoting
            if($key[$i] == '"') {
                if(!$openQuote) {
                    if($openDoubleQuote) {
                        $openDoubleQuote = false;
                    } else {
                        $openDoubleQuote = true;
                    }
                    continue;
                }
            }
            if($key[$i] == "'") {
                if(!$openDoubleQuote) {
                    if($openQuote) {
                        $openQuote = false;
                    } else {
                        $openQuote = true;
                    }
                    continue;
                }
            }

            // Handle dotted keys
            if($key[$i] == "." && !$openQuote && !$openDoubleQuote) {
                if(is_array($pointer)) {
                    if(!isset($pointer[$buff])) {
                        $pointer[$buff] = new stdClass();
                    }
                    $pointer = & $pointer[$buff];
                } else {
                    if(!isset($pointer->{$buff})) {
                        $pointer->{$buff} = new stdClass();
                    }
                    $pointer = & $pointer->{$buff};
                }

                // Cleanup buffer
                $buff = '';
                continue;
            }

            $buff .= $key[$i];
        }

        if(is_array($pointer)) {
            $pointer[$buff] = self::parseValue( $val );
        } else {
            $pointer->{$buff} = self::parseValue( $val );
        }

        return $buff;
    }