Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Omit empty attributes #110

Merged
merged 1 commit into from
Mar 4, 2017
Merged

Omit empty attributes #110

merged 1 commit into from
Mar 4, 2017

Conversation

f3ath
Copy link
Contributor

@f3ath f3ath commented Mar 4, 2017

Issue

According to the standard, the attributes member of the resource must be an object. If the attributes list is empty, json_encode treats it as an array, producing invalid output like this:

{"data":{"type":"posts","id":"1","attributes":[]}}

This behavior breaks some clients which expect attributes to be an object, not an array. In the same time, attributes is an optional member.

Proposed solution

Omit empty attributes in the resulting json.

@tobyzerner tobyzerner merged commit e3a5bbb into tobyzerner:master Mar 4, 2017
@tobyzerner
Copy link
Owner

Beaut, thanks :)

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

Successfully merging this pull request may close these issues.

2 participants