Provide phutil_json_encode()
Summary:
Ref T8672. Various issues like T8672 and T5955 are more difficult to understand and debug because we are not careful about checking for JSON encoding errors.
Add an error checking JSON encoder. This will let us raise an issue at the source of the problem, instead of further down the pipeline.
Test Plan: Added and executed unit tests.
Reviewers: btrahan, joshuaspence
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T8672
Differential Revision: https://secure.phabricator.com/D13444