json.count: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page json.count to Json.count without leaving a redirect: Converting page title to first-letter uppercase)
m (Conversion script moved page Json.count to json.count: Converting page titles to lowercase)
(No difference)

Revision as of 23:15, 9 February 2023

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 0 is returned. The index for the JSON Array starts at 0.

Usage

json.count(array, value)]
json.count(array, value, start)]

Parameters

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

Example

Find the number of occurrences of 1:
[r: json.count("[1,2,3,1,1,3]", 1)]

Returns 3

Find the number of occurrences of 1, starting at index 1:

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

See Also