1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-14 20:20:30 +00:00

Add note about special JSON values in docs for textutils.unserializeJSON (#1058)

This commit is contained in:
JackMacWindows 2022-05-07 06:10:25 -04:00 committed by GitHub
parent 87a1c1a525
commit f5f0c7990a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -657,6 +657,9 @@ do
-- This may be used with @{textutils.serializeJSON}, or when communicating -- This may be used with @{textutils.serializeJSON}, or when communicating
-- with command blocks or web APIs. -- with command blocks or web APIs.
-- --
-- If a `null` value is encountered, it is converted into @{textutils.json_null}.
-- If an empty array is encountered, it is converted into @{textutils.empty_json_array}.
--
-- @tparam string s The serialised string to deserialise. -- @tparam string s The serialised string to deserialise.
-- @tparam[opt] { nbt_style? = boolean, parse_null? = boolean } options -- @tparam[opt] { nbt_style? = boolean, parse_null? = boolean } options
-- Options which control how this JSON object is parsed. -- Options which control how this JSON object is parsed.
@ -671,6 +674,8 @@ do
-- @treturn[2] nil If the object could not be deserialised. -- @treturn[2] nil If the object could not be deserialised.
-- @treturn string A message describing why the JSON string is invalid. -- @treturn string A message describing why the JSON string is invalid.
-- @since 1.87.0 -- @since 1.87.0
-- @see textutils.json_null Use to serialize a JSON `null` value.
-- @see textutils.empty_json_array Use to serialize a JSON empty array.
unserialise_json = function(s, options) unserialise_json = function(s, options)
expect(1, s, "string") expect(1, s, "string")
expect(2, options, "table", "nil") expect(2, options, "table", "nil")
@ -784,6 +789,8 @@ unserialise = unserialize -- GB version
-- times. -- times.
-- @usage textutils.serializeJSON({ values = { 1, "2", true } }) -- @usage textutils.serializeJSON({ values = { 1, "2", true } })
-- @since 1.7 -- @since 1.7
-- @see textutils.json_null Use to serialize a JSON `null` value.
-- @see textutils.empty_json_array Use to serialize a JSON empty array.
function serializeJSON(t, bNBTStyle) function serializeJSON(t, bNBTStyle)
expect(1, t, "table", "string", "number", "boolean") expect(1, t, "table", "string", "number", "boolean")
expect(2, bNBTStyle, "boolean", "nil") expect(2, bNBTStyle, "boolean", "nil")