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

ArraySerializer docs are incorrect #388

Open
brandonkelly opened this issue May 18, 2017 · 4 comments
Open

ArraySerializer docs are incorrect #388

brandonkelly opened this issue May 18, 2017 · 4 comments
Labels

Comments

@brandonkelly
Copy link

brandonkelly commented May 18, 2017

The example given for how Collections with metadata are serialized using ArraySerializer is incorrect:

// Collection with Meta
[
    [
        'foo' => 'bar'
    ]
    'meta' => [
        ...
    ]
];

In reality it will be:

// Collection with Meta
[
    'data' => [
        [
            'foo' => 'bar'
        ]
    ],
    'meta' => [
        ...
    ]
];

Other parts of the ArraySerializer docs give it a bad wrap as well, for no good reason, as the collections do in fact get tucked inside a data attribute.

As far as I can tell, there’s only two differences between ArraySerializer and DataArraySerializer:

  1. ArraySerializer serializes the resource at the top level rather than under a data key
  2. ArraySerializer respects the resourceKey it was configured with; DataArraySerializer forces 'data'
@Art4
Copy link
Contributor

Art4 commented May 19, 2017

Note: The fractal docs samples are in PHP array notation form, not JSON. The were produced with $manager->createData($resource)->toArray(); not ->toJson().

I was confused by this too, see #206 (comment)

@brandonkelly
Copy link
Author

@Art4 Thanks, updated the OP

@willishq
Copy link
Member

I'll pick this up this evening, thanks for letting us know!

@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 4 weeks if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants