Skip to content

[Serializer] Impossible to use UnwrappingDenormalizer with scalar denormalization #38983

Closed
@Sajito

Description

@Sajito

Symfony version(s) affected: 5.1.8

Description
It's impossible to denormalize into a scalar value when using the unwrap path feature, because the scalar value check is done before applying the UnwrappingDenormalizer.

How to reproduce

use Symfony\Component\Serializer\Normalizer\UnwrappingDenormalizer;

$result = $serializer->deserialize(
    '{"baz": "test"}',
    'string',
    'json',
    [UnwrappingDenormalizer::UNWRAP_PATH => '[baz]']
);

// expected result
// $result === "test"

// actual result
// Symfony\Component\Serializer\Exception\NotNormalizableValueException: Data expected to be of type "string" ("array" given).

Possible fix
Introduce a ScalarDenormalizer instead of checking the target type inside the Serializer class.

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy