Searches containers and sub-containers for all occurrences of a key or index and returns the number of instances found.
jsKeyExist ( container-handle, key-name [, ptr-paths [, key-delimiter]] )
(s) container-handle: handle to an object or array that is at the root of the returned paths.
(s) key-name: JSON key name with optional array index to search for or empty string ("") to return all paths. The key name can optionally be proceeded by partial path information.
(s) ptr-paths: [optional] WIL pointer to a variable that contains the JSON paths of each found key-name upon function return. Use the WIL ampersand(&) operator to create a pointer to a variable.
(s) key-delimiter: [optional] single character used between key names in a path (defaults to a dot character(".")).
(i) key-count: number of key-name instances found in the container-handle JSON container. Can be zero(0).
JSON containers hold either key/value pairs or indexed values. Use jsKeyPaths check for the existents key-name in a container or sub-container. Since it is possible to have multiple indexed values or pairs with the same index or key name, the function returns the number of instances found. When no instances of a key-name are found the function returns zero(0). Optionally, the function can return the unique JSON path for each instance in the variable pointed to by the ptr-paths parameter. See the discussion below for more information about the extender's JSON paths.
Container-Handle
The unique identifier returned from a call to the jsParse, jsConNew, jsValueGet functions, or by accessing WIL map element returned by the jsConMap function.
Key-Name
The name of the key to search for in the JSON container or an empty string ("") to search the paths to all values in the container and any sub-containers. The Key-Name parameter can include a JSON array name with index or an anonymous array "[]" with an index.
This parameter can optionally include partial JSON path information. The path information restricts the key-name search to the container named before the last name in the supplied path. The last name in the path is the search target key-name. The optional path information must include a complete path to the desired search starting point. If the path does not start with a container name in the JSON handle container or contains nonexistent container name, the function will return 0. See the About JSON Paths topic for more information about the extender's JSON paths.
Important:
JSON key names are case sensitive, so make sure the key-name is spelled correctly and matches the case of the key stored in the JSON data.
A key-name and any path container names must always be surrounded by square brackets when the name contains embedded square brackets or the current key-name delimiter.
Ptr-Paths
This optional parameter must contain a WIL pointer to a variable that receives the paths of all found key-names as a WIL array. The function returns an empty array (WIL array with no elements) when the supplied key-name does not exist in the container or one of the containers's sub-containers.
Notes:
Key-Delimiter
This optional parameter is a single character used between key-names in the input and is also used by the function in the output paths. The default value is a dot (".") and the space(' '), backslash('\'), single-quote("'"), double-quote('"'), dollar-sign("$"), left-bracket("["), right-bracket("]") and grave-accent("`") cannot be used as delimiters.
A JSON paths consists of a series of key names. Each key name is delimited by a character of your choice and is associated with a JSON container. See the About JSON Paths topic for more information about the extender's JSON paths.
AddExtender('ilcjs44i.dll', 0, 'ilcjs64i.dll') ; Note: items with a "label" key display text that ; differs form he item's "id". jsonData = $" "header":: "SVG Viewer", "items":: [ {"id":: "Open"}, {"id":: "OpenNew", "label":: "Open New"}, null, {"id":: "ZoomIn", "label":: "Zoom In"}, {"id":: "ZoomOut", "label":: "Zoom Out"}, {"id":: "OriginalView", "label":: "Original View"}, null, {"id":: "Quality"}, {"id":: "Pause"}, {"id":: "Mute"}, null, {"id":: "Find", "label":: "Find..."}, {"id":: "FindAgain", "label":: "Find Again"}, {"id":: "Copy"}, {"id":: "CopyAgain", "label":: "Copy Again"}, {"id":: "CopySVG", "label":: "Copy SVG"}, {"id":: "ViewSVG", "label":: "View SVG"}, {"id":: "ViewSource", "label":: "View Source"}, {"id":: "SaveAs", "label":: "Save As"}, null, {"id":: "Help"}, {"id":: "About", "label":: "About Adobe CVG Viewer..."} ] }}$" Json = jsParse(jsonData) ; Get the displayed names of all menu items in the above ; JSON data. displaytext = "" ; Get a handle to the items array arrItems = jsValueGet(Json, "[menu].[items]") itemmax = jsGetInfo(4, arrItems) - 1 For i=0 To itemmax If jsKeyExist(arrItems, "[][%i%].label", &paths) displaytext := jsValueGet(arrItems, paths[0] ):@lf ElseIf jsKeyExist(arrItems, "[][%i%].id", &paths) displaytext := jsValueGet(arrItems, paths[0] ) :@lf Else displaytext := "-":@lf ; separator EndIf Next Message("Menu Items Displayed Text", displaytext) Exit