Skip to content

Map to different property name #19

Answered by romm
mariosimao asked this question in Q&A
Discussion options

You must be logged in to vote

First of all, what a useful library!

🤗

How to map properties different from JSON keys?

I've already thought about this case, though I did not try a solution nor documented anything related to it.

I just tried something locally, but I spotted a bug that needs to be fixed in order for the code below to work (I'll work on it ASAP).

final class KeyReplacementSource implements IteratorAggregate
{
    /** @var mixed[] */
    private array $source;

    /**
     * @param iterable<mixed> $source
     * @param array<string, string> $keyReplacements
     */
    public function __construct(iterable $source, array $keyReplacements)
    {
        $this->source = $this->replace($source, $keyReplace…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@romm
Comment options

@brayniverse
Comment options

Answer selected by mariosimao
Comment options

You must be logged in to vote
1 reply
@romm
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants