RPTools

Personal tools
From MapToolDoc

json.contains

Contents

json.contains() Function

Introduced in version 1.3b49

Returns true(1) if the JSON Object contains the specified key, or if the JSON Array contains the specified value.

Usage

  1. json.contains(object, key)
  1. json.contains(array, value)

Parameters

  • object - The JSON Object to test for the key.
  • key - The key to check the object for.
  • array - The JSON Array to test for the value.
  • value - The value to check the array for.

Examples

Check if the JSON Object a contains the key "b":

  1. [h:a=json.fromStrProp("a=1;b=44;c=12")]
  2. [json.contains(a,"b")]

Returns true(1)

Check if the JSON Object a contains the key "z":

  1. [h:a=json.fromStrProp("a=1;b=44;c=12")]
  2. [json.contains(a,"z")]

Returns false(0)

Check if the JSON Array a contains the value "b":

  1. [h:a=json.fromList("1,b,3,d")]
  2. [json.contains(a,"b")]

Returns true(1)

See Also

json.type()

Version Changes

  • 1.3b51 - Added ability for function to work with JSON Arrays.