Skip to content

Deserializing from json file #72

@lolaslade

Description

@lolaslade

I am using this class on a few entities. When trying to de-serialize a translation entity from a JSON file in a command line context - in this case it's phpunit I am getting an error:

Error: Typed property App\Entity\MyDomain\MyType::$locale must not be accessed before initialization

This happens whether I put the locale property in the JSON file or not.

Being pretty new to Symfony, I am not sure how to proceed. Do I need to create a custom normalizer as per these docs, plus maybe a context? https://symfony.com/doc/current/serializer/custom_normalizer.html

Or do I just have the normalizationContext settings in the attributes incorrect?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions