json.type: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(New page: ==Function json.type== '''Introduced in MapTool 1.3b49''' Returns a string which contains the type of Macros:json object that is passed in. Return values are * ARRAY - The object ...)
 
No edit summary
 
(8 intermediate revisions by 5 users not shown)
Line 1: Line 1:
==Function json.type==
{{MacroFunction
 
|name=json.type
 
|version=1.3b49
 
|description=
'''Introduced in MapTool 1.3b49'''
Returns a string which contains the type of JSON variable that is passed in.
 
Returns a string which contains the type of [[Macros:json object|json object]] that is passed in.
Return values are
Return values are
* ARRAY - The object is a [[Macros:json array|json array]].
* {{code|ARRAY}} - The object is a [[JSON Array]].
* OBJECT - The object is a [[Macros:json object|json object]].
* {{code|OBJECT}} - The object is a [[JSON Object]].
* UNKNOWN - It is neither a [[Macros:json array|json array]] or [[Macros:json object|json object]].
* {{code|UNKNOWN}} - It is neither a [[JSON Array]] nor [[JSON Object]].
 


===Usage===
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[h: jarr = json.type(val)]
[h: jarr = json.type(val)]
</source>
</syntaxhighlight>
 


===Examples===
|examples=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
   [h:a=json.fromStrProp("a=1;b=44;c=12")] [r:json.type(a)]
   [h:a=json.fromStrProp("a=1;b=44;c=12")] [r:json.type(a)]
   [h:a=json.fromList("a,1,g,4")][r:json.type(a)]
   [h:a=json.fromList("a,1,g,4")][r:json.type(a)]
   [r:json.type("some thing or other")]
   [r:json.type("some thing or other")]
</source>
</syntaxhighlight>


Returns
Returns
Line 28: Line 26:
   ARRAY
   ARRAY
   UNKNOWN
   UNKNOWN
}}
[[Category:JSON Function]]

Latest revision as of 23:59, 15 March 2023

json.type() Function

Introduced in version 1.3b49
Returns a string which contains the type of JSON variable that is passed in.

Return values are

 

Usage

[h: jarr = json.type(val)]

Examples

  [h:a=json.fromStrProp("a=1;b=44;c=12")] [r:json.type(a)]
  [h:a=json.fromList("a,1,g,4")][r:json.type(a)]
  [r:json.type("some thing or other")]

Returns

 OBJECT
 ARRAY
UNKNOWN