Object-functions

All object-functions are statically bound to "object" -namespace. Namespace may be omitted, unless otherwise instructed in the notes. If output-type is other than Object then it is explicitly written out.

count() <Number>

Count returns the number of key-value pairs that the input object has.

Example

hasKey($key) <Boolean>

Returns true if the $key is found from the input object, otherwise false.

Example

key() <String>

Key returns the first key of the input object.

Example

key($index <Number>) <String>

Key with $index argument returns the key from the given index.

Example

keys() <Array>

Keys returns all input-object keys as an Array.

Example

valueKey() <String>

ValueKey returns the input-value's (could be any type) parent-object's key. If there is no parent-key, then if object has only one key-pair, then takes the first key, otherwise returns empty-value.

Example

Example

Example

value() <JSON>

Value without argument returns the first value from the input-object.

Example

value($key <String Or Number>) <JSON>

Value returns the value from the input-object decided by the $key-argument. If $key is String, then returns value from the associated key. If $key is Number, then returns the value from the associated position. If the number is negative, then returns the value starting from the end of the object.

Example

Example

values() <Array>

Values returns all the values from the input-object.

Example

random($options <Object>)

Random returns the random pairs from the object.

Options

  • $count tells how many values are taken.
  • $seed (Number, optional) controls the seed for the pseudo random-number generator.

Example

remove($key <String Or Number>)

Remove removes the key-pair from the input-object, based on the given $key-argument. If $key is String, then removes value from the associated key. If $key is Number, then removes the value from the associated position. If the number is negative, then this removes the value starting from the end of the object.

Example

Example

Example

rename($key <String Or Number>, $to)

Rename renames the key from the input-object, based on the given $key-argument, into the name given by $to-argument. If $key is String, then renames the associated key. If $key is Number, then renames the key from the associated position. If the number is negative, then this renames the key starting from the end of the object.

NOTE: for $to-argument the current-value (Object) is set to key which is to be renamed (i.e. the old key), so this can be used to evaluate the new key-value.

Example

Example

Example

update($value, $target <String Or Number>)

Update changes the value behind the key from the input-object, based on the given $target-argument, into value given in the $value-argument.

If $target is String, then updates the value associated with the key.

If $target is Number, then updates the value from the associated position. If the number is negative, then this updates the value starting from the end of the object.

If no $target is given, then all items are updated.

NOTES:

  • For $target-argument the current-value is set to key-pair which is to be updated (i.e. an Object), so this can be used to evaluate also the key to be updated. See the second example.
  • For $value-argument the current-value is set to key-pair which is to be updated (i.e. the value), so this can be used to evaluate the new value.

Example

Example

Example

Example

createPair($key <String>, $value)

CreatePair adds a new key-value pair into the input-object. The key is decided by the $key-argument and value by the $value-argument.

Example

Example