From 0b15a2c3fdbbab381fde6c7305c2967d0dcee451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aziz=20K=C3=B6ksal?= Date: Thu, 4 Feb 2021 20:29:46 +0100 Subject: [PATCH] Added encodable_key type. Changed encodable to not use decoded. --- lib/jason.ex | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/jason.ex b/lib/jason.ex index 72b5705..09f5bf7 100644 --- a/lib/jason.ex +++ b/lib/jason.ex @@ -15,7 +15,7 @@ defmodule Jason do @typedoc "The type of the value returned by the custom decoder function." @type map_key :: term @typedoc "Decoding setting for map keys." - @type keys :: :atoms | :atoms! | :strings | :copy | (String.t() -> map_key) + @type keys :: :atoms | :atoms! | :strings | :copy | (key :: String.t() -> map_key) @typedoc "Decoding setting for strings." @type strings :: :reference | :copy @typedoc "Decoding setting for floats." @@ -29,8 +29,10 @@ defmodule Jason do @type value :: nil | String.t() | number | boolean | [value] | %{String.t() => value} @typedoc "A decoded JSON value where map keys can have any type." @type decoded :: [decoded] | %{map_key => decoded} | value - @typedoc "The types that may be encoded. Only tuples are not included." - @type encodable :: decoded | atom + @typedoc "The map key types that can be encoded." + @type encodable_key :: String.t() | number | atom | [encodable_key] + @typedoc "The types that can be encoded. Not included are: `tuple`s, `function`s, `reference`s, `port`s and `pid`s." + @type encodable :: String.t() | number | atom | [encodable] | %{encodable_key => encodable} @doc """ Parses a JSON value from `input` iodata.