Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML mapping doesn't map XmlKeyValuePairs but works for JSON #521

Closed
bentcoder opened this issue Jul 14, 2016 · 0 comments
Closed

XML mapping doesn't map XmlKeyValuePairs but works for JSON #521

bentcoder opened this issue Jul 14, 2016 · 0 comments

Comments

@bentcoder
Copy link

Does anyone know why XML mapping for extended property doesn't work as it does for JSON version?

MODEL

namespace My\Bundle\Model;

use JMS\Serializer\Annotation as Serializer;

/**
 * @Serializer\XmlRoot("product")
 */
class Create
{
    /**
     * @Serializer\Type("string")
     */
    public $title;

    /**
     * @Serializer\Type("array<string, string>")
     * @Serializer\XmlKeyValuePairs
     */
    public $extended;
}

JSON REQUEST

{
    "title": "Created name",
    "extended": {
        "crt_key_1": "crt_val_1",
        "crt_key_2": "crt_val_2"
    }
}

Mapping result

My\Bundle\Model\Create Object
(
    [title] => Created name
    [extended] => Array
        (
            [crt_key_1] => crt_val_1
            [crt_key_2] => crt_val_2
        )
)

XML REQUEST

<?xml version="1.0" encoding="UTF-8"?>
<product>
    <title>Created name</title>
    <extended>
        <crt_key_1>crt_val_1</crt_key_1>
        <crt_key_2>crt_val_2</crt_key_2>
    </extended>
</product>

Mapping result

My\Bundle\Model\Create Object
(
    [title] => Created name
    [extended] => Array
        (
        )
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants