Skip to content

[Serializer] @SerializedName flattening nested attributes #32080

Closed
@piotrooo

Description

@piotrooo

Description
Sometimes I want to flatten a JSON object into POPHPO.
For example Jackson provide following feature in annotation: @JsonProperty("filter.key1").
@JsonProperty like annotation should handle nested values.

Example

Following JSON:

{
    "key1": "value1"
    "nested": {
          "sub_key1": "sub_value1"
          "sub_key2": "sub_value2"
     }
}

And unmarshalled object:

class Obj
{
    /**
     * @JsonProperty('key1')
     * @var string
     */
    private @name;
    /**
     * @JsonProperty('nested.sub_key1')
     * @var string
     */
    private @other;
    /**
     * @JsonProperty('nested.sub_key2')
     * @var string
     */
    private @anotherAgain;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureHelp wantedIssues and PRs which are looking for volunteers to complete them.Serializer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions