Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Serializer] array<string, list<Foo>> cannot be denormalized if nested under list<Bar> #60036

Open
@ostrolucky

Description

@ostrolucky

Symfony version(s) affected

5.4, 6.x, 7.x

Description

If array with string key but list is nested under object with a list (like in a reproducer), Denormalizer seems to skew the key from string into int, resulting into error:

Symfony\Component\Serializer\Exception\NotNormalizableValueException : The type of the key "something" must be "int" ("string" given).

How to reproduce

Phpunit reproducer athttps://github.com/symfony/symfony/compare/7.3...ostrolucky:list-nesting-reproducer?expand=1

In comment form:

class Foo {/** @param array<string, list<\stdClass>> $operators */publicfunction__construct(publicarray$operators = []) {}}class Bar {/** @param list<Foo> $foos */publicfunction__construct(publicarray$foos = []) {}}
publicfunctiontestPropertyPhpDocWithKeyTypes(){$json =<<<JSON    {    "foos": [{"operators": {"something": [{}]}}]    }    JSON;$serializer =newSerializer([newObjectNormalizer(null,null,null,newPhpDocExtractor()),newArrayDenormalizer(),    ], ['json' =>newJsonEncoder()]);$serializer->deserialize($json, Bar::class,'json');}

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp