structKeyList

Extracts keys from a CFML structure.

structKeyList(structure [, delimiter]) → returns String

Member Function Syntax

someStruct.keyList([delimiter])

Argument Reference for the structKeyList function

structure

Required: Yes
Structure from which to extract a list of keys

delimiter

Required: No
Default: ,
Character that separates keys in list. Default: comma. Values:
  • ,
  • |
  • ;
  • chr(9)
  • chr(10)
  • chr(13)

Examples sample code invoking the structKeyList function


Using Custom Delimiter

Retrieve a pipe seperated list of keys

statusCodes = {
    OK = 200,
    CREATED = 201,
    NOT_MODIFIED = 304,
    BAD_REQUEST = 400,
    NOT_FOUND = 404
};

writeDump(structKeyList(statusCodes, " | "));

Expected Result: "OK | CREATED | NOT_MODIFIED | BAD_REQUEST | NOT_FOUND"


Using Member Function

CF 11+ Lucee 4.5+ Retrieve a comma seperated list of keys using the member function

statusCodes = {
    OK = 200,
    CREATED = 201,
    NOT_MODIFIED = 304,
    BAD_REQUEST = 400,
    NOT_FOUND = 404
};

writeDump(statusCodes.keyList());

Expected Result: "OK,CREATED,NOT_MODIFIED,BAD_REQUEST,NOT_FOUND"


Fork me on GitHub