json.indexOf

From RPTools Wiki
Revision as of 13:02, 29 March 2009 by Craig (talk | contribs) (New page: {{MacroFunction |name=json.indexOf |version=1.3b53 |description= Returns the index of the first occurrence of a value in the JSON Array. If the value does not exist in the [[JSON Array...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

json.indexOf() Function

Introduced in version 1.3b53
Returns the index of the first occurrence of a value in the JSON Array. If the value does not exist in the JSON Array then -1 is returned. All JSON Array indexes start at 0.

Usage

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

Parameters

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

Example

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

Returns 0

3