Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong key when combining list and scalar value pointers #110

Open
daniel-sc opened this issue Feb 21, 2024 · 1 comment
Open

Wrong key when combining list and scalar value pointers #110

daniel-sc opened this issue Feb 21, 2024 · 1 comment

Comments

@daniel-sc
Copy link

When combining a pointer to a list and a pointer to a scalar value, and the scalar is after the list (does not happen when scalar before list!), then the key of the scalar is not correct.

Example:

        $response = '{
            "items": [
                {
                    "item_id": 1,
                    "external_id": "some id 1"
                },
                {
                    "item_id": 2,
                    "external_id": "some id 2"
                }
            ],
            "total": 2
            }';
        $json = Items::fromString($response, ['pointer' => ['/items', '/total']]);
        foreach ($json as $key => $value) {
            echo "key=" . $key . "\n";
        }

This outputs:

key=0
key=1
key=2

Expected/correct output would be:

key=0
key=1
key=total
@halaxa
Copy link
Owner

halaxa commented Jul 11, 2024

Hi, thanks for reaching out, and sorry for the delay. I had much stuff going on in life 😄. I'll try looking into it soon. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants