json.evaluate: Difference between revisions
Jump to navigation
Jump to search
m (Conversion script moved page Json.evaluate to json.evaluate: Converting page titles to lowercase) |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 7: | Line 7: | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
json.evaluate(array) | json.evaluate(array) | ||
</ | </syntaxhighlight> | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
json.evaluate(object) | json.evaluate(object) | ||
</ | </syntaxhighlight> | ||
'''Parameters''' | '''Parameters''' | ||
* {{code|array}} - The JSON array which has its contents evaluated. | * {{code|array}} - The JSON array which has its contents evaluated. | ||
Line 19: | Line 19: | ||
|example= | |example= | ||
Using {{code|json.eval}} on an {{code|array}} and an {{code|object}}. | Using {{code|json.eval}} on an {{code|array}} and an {{code|object}}. | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[H: run = json.append("","[r: 1d6]")] | [H: run = json.append("","[r: 1d6]")] | ||
[R: json.evaluate(run)]<br> | [R: json.evaluate(run)]<br> | ||
[H: run = json.set("{}","roll","{3d6}")] | [H: run = json.set("{}","roll","{3d6}")] | ||
[R: json.evaluate(run)] | [R: json.evaluate(run)] | ||
</ | </syntaxhighlight> | ||
'''Output:''' | '''Output:''' | ||
< | <syntaxhighlight lang="mtmacro"> | ||
[5] | [5] | ||
{"roll":11} | {"roll":11} | ||
</ | </syntaxhighlight> | ||
|also= | |also= |
Latest revision as of 23:59, 15 March 2023
json.evaluate() Function
Note: This function can only be used in a Trusted Macro
• Introduced in version 1.3b51
Traverses a JSON array or JSON object and evaluates any macro code or rolls contained within. All macro code and rolls are evaluated against the current token. This function works like evalMacro().
Usage
json.evaluate(array)
json.evaluate(object)
Parameters
array
- The JSON array which has its contents evaluated.object
- The JSON object which has its contents evaluated.
Example
Using
json.eval
on an array
and an object
.
[H: run = json.append("","[r: 1d6]")]
[R: json.evaluate(run)]<br>
[H: run = json.set("{}","roll","{3d6}")]
[R: json.evaluate(run)]
Output:
[5]
{"roll":11}