json.count

From RPTools Wiki
Revision as of 12:50, 29 March 2009 by Craig (talk | contribs) (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...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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.

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