json.toList: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(New page: ==Function json.toList== '''Introduced in MapTool 1.3b49''' Creates a Macros:string list from a Macros:json array. ===Usage=== <source lang="mtmacro" line> [h: jarr = json....)
 
No edit summary
 
(10 intermediate revisions by 5 users not shown)
Line 1: Line 1:
==Function json.toList==
{{MacroFunction
|name=json.toList
|version=1.3b49
|description=
Creates a [[Macros:string list|string list]] from a [[JSON Array]]. If the delimiter is not specified then the default value of ',' is used.


|usage=
<syntaxhighlight lang="mtmacro" line>
[h: jarr = json.toList(jarr)]
[h: jarr = json.toList(jarr, delim)]
</syntaxhighlight>


'''Parameters'''
{{param|jarr|JSON Array}}
{{param|delim|Delimiter used in output}}


'''Introduced in MapTool 1.3b49'''
|examples=
<syntaxhighlight lang="mtmacro" line>
  [h:a=json.fromList("a,1,g,4")]
  [json.toList(a)]
</syntaxhighlight>


Creates a [[Macros:string list|string list]] from a [[Macros:json array|json array]].
Returns
<syntaxhighlight lang="mtmacro">
    a,1,g,4
</syntaxhighlight>


===Usage===
}}
<source lang="mtmacro" line>
[[Category:JSON Function]]
[h: jarr = json.toStrProp(jobj)]
</source>
 
 
===Examples===
<source lang="mtmacro" line>
  [h:a=json.fromList("a,1,g,4")][r:json.toList(a)]
  [h:a=json.fromStrProp("a=1;b=44;c=12")] [r:json.toList(a)]
</source>
 
Returns
  a=1;c=12;b=44
  a,c,b

Latest revision as of 17:38, 15 March 2023

json.toList() Function

Introduced in version 1.3b49
Creates a string list from a JSON Array. If the delimiter is not specified then the default value of ',' is used.

Usage

[h: jarr = json.toList(jarr)]
[h: jarr = json.toList(jarr, delim)]

Parameters

  • jarr - JSON Array
  • delim - Delimiter used in output

Examples

  [h:a=json.fromList("a,1,g,4")]
  [json.toList(a)]

Returns

     a,1,g,4