Skip to content
New issue

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

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

Already on GitHub? # to your account

Plain arrays are serialized (normalized) as "objects", ignoring serializeNull #641

Closed
scaytrase opened this issue Sep 8, 2016 · 3 comments

Comments

@scaytrase
Copy link
Contributor

As soon as I have no response in original closed issue #571 , I've open a new one

Given commit b0a46c8 does not solve the problem - plain arrays are still serialized as object:

test/JMS/Serializer/Tests/Serializer/ArrayTest.php

    public function testNullArraySerialization()
    {
        $context = SerializationContext::create();
        $context->setSerializeNull(true);
        $array = [0, null, 'a'];
        self::assertSame($array, $this->serializer->toArray($array, $context));
    }
Failed asserting that Array &0 (
    0 => 0
    2 => 'a'
) is identical to Array &0 (
    0 => 0
    1 => null
    2 => 'a'
).

How we force an array being normalized as array, not object? I'll try to file this failing test as pull request if you need it.

As a solution I propose to make this check
https://github.com/schmittjoh/serializer/blob/master/src/JMS/Serializer/GenericSerializationVisitor.php#L101
look like others
https://github.com/schmittjoh/serializer/blob/master/src/JMS/Serializer/YamlSerializationVisitor.php#L84-L85

scaytrase added a commit to bankiru/serializer that referenced this issue Sep 8, 2016
@goetas
Copy link
Collaborator

goetas commented Sep 9, 2016

related to #626 ?

@scaytrase
Copy link
Contributor Author

Yes, thanks. I haven't re-check new issues about this since my closed #571

@goetas
Copy link
Collaborator

goetas commented Oct 23, 2016

related to #626

@goetas goetas closed this as completed Oct 23, 2016
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants