Skip to content

[Serializer] @SerializedName flattening nested attributes #32080

@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

      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