json.intersection

From RPTools Wiki
Revision as of 08:12, 10 July 2013 by Bone White (talk | contribs) (Added more information and another example.)
Jump to navigation Jump to search

 This article is a stub, you can help the RPTools Wiki project by contributing content to expand this article.
 This article needs: Examples of usage, and clearer description.

json.intersection() Function

Introduced in version 1.3b53
Returns a JSON Array with the intersection of all of the JSON Object keys or JSON Array values. An value or key only appears in the output if it exists in all input arrays or objects. This function is useful for removing Token IDs from a saved list which have been deleted from the map by eliminating them using this function, the saved array and getTokens().

Usage

json.intersection(array, array, ...)
json.intersection(object, object, ...)

Parameters

Examples

  [h: array1 = json.append("",1,2,3,4)]
  [h: array2 = json.append("",3,4,5,6)]
  [r: json.intersection(array1,array2)]

Returns

"[3,4]"


  [h: arrayOfSelectedNames = getSelectedNames("json")]
  [h: arrayOfNamesOnMap = getTokenNames("json")]
  [r: json.intersection(arrayOfSelectedNames,arrayOfNamesOnMap)]

Input

arrayOfSelectedNames = ["Alexander","Josh"]
arrayOfNamesOnMap = ["Kevin","Josh","Alexander"]

Returns

["Alexander","Josh"]

See Also