Syntax
json.type(value: any): stringArguments
| Name | Type | Description |
|---|---|---|
value | any | Value to classify. Passing no value returns the runtime type name for a missing stack value. |
Returns
| Name | Type | Description |
|---|---|---|
jsonType | string | Type name string. Verified JSON-specific returns are "null", "array", and "object". Non-table, non-json.null values use Lua type name, such as "nil", "boolean", "number", "integer", "string", "function", "object", "thread", "buffer", "class", "object", "vector", or "no value" depending on the runtime value. |
Description
Returns a string type name for a value. json.null returns "null". Tables return "array" or "object" using the same table classification as json.isArray and json.isObject. Other values return the runtime Lua type name result.
Call it with 1 parameter(s): value. The argument table explains which values are required and which ones only refine the behavior.
It returns jsonType (string). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Check the exact type string returned by the JSON helper.
print(json.type(json.array({ "red", "blue" })))
print(json.type(json.object({ enabled = true })))
print(json.type(json.null))
print(json.type(nil))
print(json.type())