Skip to content

Commit 4cbedda

Browse files
authored
Document module requirements for json_library() (see PR #6481) (#6732)
1 parent 3bc6984 commit 4cbedda

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

lib/phoenix.ex

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ defmodule Phoenix do
4343
4444
config :phoenix, :json_library, AlternativeJsonLibrary
4545
46+
The configured module is required to provide three functions:
47+
48+
- **`decode!/1`** — decodes a JSON binary, raising on invalid input
49+
- **`encode!/1`** — encodes a term to a JSON binary, raising on encoding errors
50+
- **`encode_to_iodata!/1`** — encodes a term to JSON as iodata, raising on
51+
encoding errors.
52+
53+
These correspond to the single-argument, raising variants of
54+
the functions provided by Elixir's built-in `JSON` module. A conforming
55+
`:json_library` module does not need to implement any other functions
56+
`JSON` has, that are not defined above.
4657
"""
4758
def json_library do
4859
Application.get_env(:phoenix, :json_library, Jason)

0 commit comments

Comments
 (0)