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

Remove casting prior to JSON serialization #64

Merged

Conversation

weierophinney
Copy link
Member

As noted on #63, casting nulls and scalars to objects and arrays, respectively, is not necessary, and likely unwanted; it could even be considered buggy behavior.

This patch eliminates the casting entirely, and updates the tests to ensure that scalars are encoded verbatim.

@franzliedke
Copy link
Contributor

👍

@weierophinney weierophinney changed the title Simplify casting null to an empty object Remove casting prior to JSON serialization Jun 25, 2015
As noted on zendframework#63, scalars and nulls can be serialized by PHP, and most
(all?) client-side parsers will deserialize them correctly. As such, the
more correct route is to pass them verbatim to `json_encode()` instead
of casting them to arrays and/or objects.
@weierophinney
Copy link
Member Author

Somehow a 100% coverage dropped to 100% leading to a -0.03% change. Stupid coveralls!

@weierophinney weierophinney merged commit 050e889 into zendframework:master Jun 25, 2015
weierophinney added a commit that referenced this pull request Jun 25, 2015
weierophinney added a commit that referenced this pull request Jun 25, 2015
weierophinney added a commit that referenced this pull request Jun 25, 2015
@weierophinney weierophinney deleted the hotfix/simplify-json-casting branch June 25, 2015 18:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants