json.count: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(New page: {{MacroFunction |name=json.count |version=1.3b53 |description= Returns the number of occurrences of a value in a JSON Array. If the value does not occur in the JSON Array then {{co...)
 
m (Clarified index start value)
Line 4: Line 4:
|description=
|description=
Returns the number of occurrences of a value in a [[JSON Array]]. If the value does
Returns the number of occurrences of a value in a [[JSON Array]]. If the value does
not occur in the [[JSON Array]] then {{code| -1}} is returned.
not occur in the [[JSON Array]] then {{code| -1}} is returned. The index for the [[JSON Array]]
starts at 0.


|usage=
|usage=

Revision as of 12:53, 29 March 2009

json.count() Function

Introduced in version 1.3b53
Returns the number of occurrences of a value in a JSON Array. If the value does

not occur in the JSON Array then -1 is returned. The index for the JSON Array

starts at 0.

Usage

[h: jarr = json.count(jarr, value)]
[h: jarr = json.count(jarr, value, startIndex)]

Parameters

  • jarr - The JSON Array to search.
  • value - The value to count the occurrences of.
  • startIndex - The index to start searching from, if not specified it defaults to 0.

Example

[r: json.count("[1,2,3,1,1,3]", 1)]
[r: json.count("[1,2,3,1,1,3]", 1, 1)]

Returns 2

3