Reference articles on history, science, culture and more
Encyclopedia

Name-value pair

Data representation method in computing systems

Image credit is listed at the end of this article.

A name-value pair, also known as an attribute-value pair, key-value pair, or field-value pair, is a fundamental data representation in computer systems and applications. Designers often desire an open-ended data structure that allows for future extension without modifying existing code or data. In such situations, all or part of the data model may be expressed as a collection of 2-tuples in the form <attribute name, value> with each element being an attribute-value pair. Depending on the particular application and the implementation chosen by programmers, attribute names may or may not be unique.

Common examples include JSON objects such as database records where a column maps to a stored value (e.g., usernamejohndoe), HTTP headers like Content-Type: text/html, and configuration files with settings expressed as settingType=1.

01Examples of use

Some of the applications where information is represented as name-value pairs are:

02Use in computer languages

Some computer languages implement name-value pairs, or more frequently collections of attribute-value pairs, as standard language features. Most of these implement the general model of an associative array: an unordered list of unique attributes with associated values. As a result, they are not fully general; they cannot be used, for example, to implement electronic mail headers (which are ordered and non-unique).

In some applications, a name-value pair has a value that contains a nested collection of attribute-value pairs. Some data serialization formats such as JSON support arbitrarily deep nesting. Other data representations are restricted to one level of nesting, such as INI file's section/name/value.

Watch videos about Name-value pairExplainers and documentaries on YouTube (opens in a new tab)

Sources and credits

This article is adapted from the Wikipedia article Name-value pair, written by its contributors and licensed under CC BY-SA 4.0. Fathomly has changed the layout, removed citation markers, navigation and maintenance notices, and adjusted punctuation. This adapted version is shared under the same license. For references, see the original article.

Images, from Wikimedia Commons:

Fathomly is not affiliated with or endorsed by the Wikimedia Foundation. Spotted a problem? Tell us.