Skip to content

Commit d7fa519

Browse files
authored
JSON: document that calendar types are encoded to ISO 8601 (#14165)
1 parent 72c5fe3 commit d7fa519

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/elixir/lib/json.ex

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ defmodule JSON do
257257
258258
## Encoding
259259
260-
Elixir built-in data structures are encoded to JSON as follows:
260+
Elixir primitive types are encoded to JSON as follows:
261261
262262
| **Elixir** | **JSON** |
263263
|------------------------|----------|
@@ -272,10 +272,19 @@ defmodule JSON do
272272
| `%{integer() => _}` | Object |
273273
274274
You may also implement the `JSON.Encoder` protocol for custom data structures.
275+
Some built-in data-structures already derive the `JSON.Encoder` protocol:
276+
277+
| **Elixir** | **JSON** |
278+
|------------------------|-----------------|
279+
| `Date.t()` | ISO 8601 string |
280+
| `Time.t()` | ISO 8601 string |
281+
| `DateTime.t()` | ISO 8601 string |
282+
| `NaiveDateTime.t()` | ISO 8601 string |
283+
| `Duration.t()` | ISO 8601 string |
275284
276285
## Decoding
277286
278-
Elixir built-in data structures are decoded from JSON as follows:
287+
Elixir types are decoded from JSON as follows:
279288
280289
| **JSON** | **Elixir** |
281290
|----------|------------------------|

0 commit comments

Comments
 (0)