# [RFC] Always available JSON extension

- Thread: https://externals.io/message/109939
- Original archive: https://news-web.php.net/php.internals/109939
- Started by tyson andre on 2020-04-30T00:20:56+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #109939 — tyson andre — 2020-04-30T00:20:56+00:00

URL: https://externals.io/message/109939#109939

Hi internals,

I've created https://wiki.php.net/rfc/always_enable_json with an implementation at https://github.com/php/php-src/pull/5495

The proposal is to make it impossible to disable the JSON extension through configuration or build options,
and require that JSON be built statically instead of as a shared library
(to avoid linker errors or extension=json being commented out).

> Currently, it's possible to disable the json extension with `./configure –disable-json`.
> However, JSON is extremely useful to have because it's widely used for many use cases
> (web sites, logging output, and as a data format that can be used to share data with 
> many applications and programming languages),
> so it would be useful for PHP maintainers and users to guarantee that json is always enabled.

Responses to earlier questions in my earlier thread "Moving json extension to core?" in https://externals.io/message/109783

> In terms of getting it passed, I'd focus on just the first part, making
> JSON a "core" builtin. Let the printf modifier be a separate RFC, or at
> least a separate question.

Agreed - limiting this to making JSON a "core" builtin (similar to "hash" in 7.4) was my intent.
The printf comment was to measure interest in a potential followup RFC that would depend on this
(and give an example of internal functionality this would allow.).

> At the risk of derailing... You can have your class implement the
> interface unconditionally, then have a polyfill definition in your autoload
> for cases where it doesn't exist. Obviously, it won't have an impact on
> calls to `json_encode()`, but if the interface doesn't exist it's because
> `json_encode()` doesn't either, so that should be harmless. :D

That would work for userland, but might cause problems if multiple PECL modules were to take that approach,
because they'd define duplicate classes. 

Thanks,
- Tyson

---

## #109980 — tyson andre — 2020-05-03T16:05:38+00:00

URL: https://externals.io/message/109939#109980 · In reply to: #109939

Hi internals,

I plan to start the vote for https://wiki.php.net/rfc/always_enable_json on May 13th

> I've created https://wiki.php.net/rfc/always_enable_json with an implementation at https://github.com/php/php-src/pull/5495
>
> The proposal is to make it impossible to disable the JSON extension through configuration or build options,
> and require that JSON be built statically instead of as a shared library
> (to avoid linker errors or extension=json being commented out).

Discussion of this idea prior to creating this RFC can be seen at https://externals.io/message/109783
("Moving json extension to core?")

Thanks,
- Tyson

---

## #109981 — Levi Morrison via internals — 2020-05-03T17:07:25+00:00

URL: https://externals.io/message/109939#109981 · In reply to: #109980

Have we reached out to package maintainers for OS distributions that are
not bundling json today to make sure all their concerns are resolved?

---

## #109982 — tyson andre — 2020-05-03T19:23:22+00:00

URL: https://externals.io/message/109939#109982 · In reply to: #109981

Hi Levi,

> Have we reached out to package maintainers for OS distributions that are not bundling json today to make sure all their concerns are resolved?

I CCed them on the GitHub PR just now.
https://github.com/php/php-src/pull/5495#issuecomment-623163698

Hopefully, this is due to packaging conventions carrying over from php 5 and there are no remaining blockers.

I didn't see this done for moving the hash extension into core, but I think most packagers were compiling it statically.

- Tyson

---

## #110140 — tyson andre — 2020-05-12T13:56:12+00:00

URL: https://externals.io/message/109939#110140 · In reply to: #109980

Hi internals,

One update before I start the vote for https://wiki.php.net/rfc/always_enable_json tomorrow (May 13th).

- After feedback from extension authors and php contributors, the C define `HAVE_JSON` will not be removed as part of this RFC.
  I'll leave it to others to decide which php version it's appropriate to remove that constant in.

> The proposal is to make it impossible to disable the JSON extension through configuration or build options,
> and require that JSON be built statically instead of as a shared library
> (to avoid linker errors or extension=json being commented out).
> 
> Discussion of this idea prior to creating this RFC can be seen at 
> https://externals.io/message/109783
> 
> ("Moving json extension to core?")

Thanks,
- Tyson
