Skip to content

JSON - Help errors bubble-up more clearly#287

Open
totten wants to merge 5 commits intocivicrm:masterfrom
totten:master-json-exception
Open

JSON - Help errors bubble-up more clearly#287
totten wants to merge 5 commits intocivicrm:masterfrom
totten:master-json-exception

Conversation

@totten
Copy link
Member

@totten totten commented Mar 4, 2026

  • Data returned by API calls is not necessarily valid for JSON (https://lab.civicrm.org/dev/core/-/issues/6364). The change in this PR is to introduce JSON_THROW_ON_ERROR (PHP 7.3+) for most JSON encoding operations.
  • This also extracts a helper Json::encode($mixed, string $format) with more preferred defaults and clearer error handling.
  • Substantively, it also tweaks some of the encoding options:
    • Tweak pretty printing to also enable JSON_UNESCAPED_UNICODE.
    • Define flat printing (which is clean JSON as a single line)

@totten totten force-pushed the master-json-exception branch from 045cb35 to d81853c Compare March 6, 2026 21:22
@totten totten changed the title JSON - Help errors bubble-up. Use helpers. JSON - Help errors bubble-up more clearly Mar 6, 2026
@totten totten force-pushed the master-json-exception branch from 7eb8544 to 3acbb9d Compare March 7, 2026 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant