Problem/Motivation

Stick to Drupal patterns.

The Json class is a serialization thing, but it is not only used through the serialization service. There are usages in common.inc, theme.inc, BlockListBuilder etc.

Proposed resolution

Replace json_encode() and json_decode() with Json::encode() and Json::decode().

Comments

arla’s picture

Status: Active » Needs review
StatusFileSize
new23.69 KB

Wow, there are way more usages than I expected.

Status: Needs review » Needs work

The last submitted patch, 1: json-functions-2507603-1.patch, failed testing.

Status: Needs work » Needs review

miro_dietiker’s picture

Status: Needs review » Needs work

Does not apply anymore... :-!

The last submitted patch, 1: json-functions-2507603-1.patch, failed testing.

miro_dietiker’s picture

Status: Needs work » Needs review
StatusFileSize
new23.26 KB

Providing new patch with the replaces.

Note that Json::encode() doesn't eat a second parameter so the pretty print / improved formatting does not work with what you uploaded.
My patch skips the ones where we need the second parameters and improving those is a second step.

Status: Needs review » Needs work

The last submitted patch, 7: collect_2507603_json.patch, failed testing.

miro_dietiker’s picture

Status: Needs work » Needs review
StatusFileSize
new24.27 KB
miro_dietiker’s picture

Status: Needs review » Needs work

The previous patch extended Json serializer with a encodePretty() version of encode(). I didn't want to override encode completely.

OK passed, committed... But still needs some improvements about that pretty print to also decide if we should add it as a service.
Should we even consider DI?

  • miro_dietiker committed 17dceef on 8.x-1.x
    Issue #2507603 by miro_dietiker, Arla: Replace json_ function calls with...