VALUES

The function VALUES takes an Object and returns a List containing all the values from the key-value pairs associated with the object.

This function takes a single Object as input. It returns a single List containing all of the values from the key-value pairs associated with the given object. The order of key-value pairs in an object is not deterministic; as a result, neither is the order of the values in the resulting list. (The VALUES function is not very useful when working with a subset, but can be useful when working with all the values of an object.)

Declaration

VALUES(object) -> list_of_values

Parameters

object (required, type: Object) Any object.

Return Values

list_of_values (type: List) A list containing all the values from the key-value pairs in the input object.

Note that the order of name-value pairs in an object is not deterministic; as a result, neither is the order of the values in the resulting list.

Examples

Assume the following example has access to the following object:

example_object = {  
 "number": 1,   
 "string1": "hello",   
 "string2": "this is a string, John",  
 "list": [1, 2, 3]  
}

Note that values in the name-value pairs within example_object consists of myriad types of values. The the value associated with "number" is a number (1), values associated with "string1" and "string2" are strings ("hello" and "this is a string, John", respectively), and the value associated with "list" is a list ( [1, 2, 3] ). This object was chosen not because it is particularly likely to be encountered it in the wild, but to emphasize that the values within an object used as input for the VALUES function do not at all need to be same type as each other. The following example takes example_object and outputs a list containing the values from the name-value pairs associated with example_object. Note that while, in this example, the order that the items in the returned list are given matches the order that the values were given in the object, this is not guaranteed to be the case. The order of key-value pairs in an object is not deterministic; as a result, neither is the order of the values in the resulting list:

VALUES(example_object) -> [1, "hello", "this is a string, John", [1, 2, 3]]

Discussion

The VALUES function takes an object and returns a List containing all of the values from the key-value pairs associated with the given object. To instead obtain list of the keys, use the function KEYS.

Last updated