HTTP Request: Allow setting JSON encoding options #212

Closed
opened 2020-11-22 23:00:13 +00:00 by jamie · 3 comments
jamie commented 2020-11-22 23:00:13 +00:00 (Migrated from git.hazaar.io)

The Hazaar\HTTP\Request class will automatically encode options into JSON when the mime content type is set to application/json. This uses the standard PHP json_encode() function with no optional flags. This creates standards compliant JSON as per ECMA-404, however there are instances where developers will have to deal with non-standards compliant systems that may require fixes being implemented via encoding flags.

I propose a new function to set these flags that we be used when encoding JSON in a request.

function setJSONEncoderFlags($flags, $depth = null);

This will store the flags and optionally a depth that will be used when calling the json_encode() function internally.

The `Hazaar\HTTP\Request` class will automatically encode options into JSON when the mime content type is set to `application/json`. This uses the standard PHP `json_encode()` function with no optional flags. This creates standards compliant JSON as per ECMA-404, however there are instances where developers will have to deal with non-standards compliant systems that may require fixes being implemented via encoding flags. I propose a new function to set these flags that we be used when encoding JSON in a request. ```php function setJSONEncoderFlags($flags, $depth = null); ``` This will store the flags and optionally a depth that will be used when calling the `json_encode()` function internally.
jamie commented 2020-11-22 23:00:19 +00:00 (Migrated from git.hazaar.io)

created merge request !107 to address this issue

created merge request !107 to address this issue
jamie commented 2020-11-22 23:00:19 +00:00 (Migrated from git.hazaar.io)

mentioned in merge request !107

mentioned in merge request !107
jamie commented 2020-11-22 23:15:26 +00:00 (Migrated from git.hazaar.io)

mentioned in commit 5fe6fa5abdb500fb4441bdc670873cfab79fc02c

mentioned in commit 5fe6fa5abdb500fb4441bdc670873cfab79fc02c
jamie (Migrated from git.hazaar.io) closed this issue 2020-11-22 23:15:26 +00:00
jamie self-assigned this 2025-09-04 01:15:28 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: hazaar/framework#212
No description provided.