/utils/keyvalue_dictionary

The keyvalue_dictionary utility method will parse a JSON object for properties with key/value pairs matching entries a provided dictionary.

The property value will be replaced with a language lookup in the dictionary or the default value.

"keyvalue_dictionary": [
  {
    "key": "name",
    "value": "OSM",
    "default": "OpenStreetMap",
    "uk": "Sława OpenStreetMap 🇺🇦"
  }
]

Methods

(inner) isArrayObject(item, dictionary) → {boolean}

Checks if an item is an array or an object and recursively applies the parsing logic.

Parameters:
NameTypeDescription
item*

The item to check.

dictionaryArray

An array of dictionary entries.

Returns:

Returns true if the item is an array or an object, false otherwise.

Type: 
boolean

(inner) keyvalue_dictionary(obj)

Replaces key-value pairs in an object with dictionary entries.

Parameters:
NameTypeDescription
objObject

The object to be mapped to keyvalue_dictionary.

(inner) parseObject(obj, dictionary)

Parses an object and replaces its string values with dictionary entries.

Parameters:
NameTypeDescription
objObject

The object to parse.

dictionaryArray

An array of dictionary entries.

(inner) replaceKeyValue(obj, key, value, dictionary)

Replaces a key-value pair in an object with a dictionary entry.

Parameters:
NameTypeDescription
objObject

The object containing the key-value pair.

keystring

The key of the value to replace.

valuestring

The value to replace.

dictionaryArray

An array of dictionary entries.