{{Short description|Data representation method in computing systems}} {{more references|date=December 2009}} [[File:Sample web form.png|thumb|right|Example of a [[HTML form|web form]] with name-value pairs]]

A '''name–value pair''', also known as an '''attribute–value pair''', '''key–value pair''', or '''field–value pair''', is a fundamental [[Data (computer science)|data]] representation in [[computer systems]] and [[Application software|applications]]. Designers often desire an open-ended [[data structure]] that allows for [[Forward compatibility|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 [[tuple|2-tuples]] in the form <code><attribute name, value&gt;</code> with each element being an attribute–value pair. Depending on the particular application and the implementation chosen by [[Programmer|programmers]], attribute names may or may not be unique.

Common examples include [[JSON]] [[Object (computer science)|objects]] such as [[Database record|database records]] where a column maps to a stored value (e.g., {{Mono|username}} → {{Mono|johndoe}}), [[HTTP headers]] like [[Content-Type]]: {{Mono|[[text/html]]}}, and [[configuration files]] with settings expressed as {{Mono|1=settingType=1}}.

== Examples of use == Some of the applications where information is represented as name-value pairs are: * [[E-mail]], in RFC 2822 headers<ref>{{Cite web|url=https://tools.ietf.org/html/rfc2822|title=Internet Message Format|last=Peter W. Resnick|website=tools.ietf.org|language=en|access-date=2018-10-02}}</ref> * [[Query string]]s, in [[Uniform resource locator|URL]]s * Optional elements in [[protocol (computing)|network protocol]]s, such as [[Internet Protocol|IP]], where they often appear as [[type–length–value|TLV]] (''type–length–value'') triples * Bibliographic information, as in [[BibTeX]] and [[Dublin Core]] metadata * Element attributes in [[SGML]], [[HTML]] and [[XML]] * [[key–value database|Key–value databases]] * [[OpenStreetMap]] map data * [[Windows registry]] entries * [[Environment variables]]

== Use in computer languages == Some [[computer language]]s 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 [[nesting (computing)|nested]] collection of attribute–value pairs. Some [[data serialization]] formats such as [[JSON]] support arbitrarily deep nesting.<ref>{{Cite web|url=https://www.w3schools.com/js/js_json_objects.asp|title=JSON Objects|website=www.w3schools.com|language=en-US|access-date=2018-10-02}}</ref> Other data representations are restricted to one level of nesting, such as [[INI file]]'s section/name/value.

==See also== * [[Attribute (computing)]] * [[Entity–attribute–value model]] * [[Query string]] * [[Key–value database]]

==References== {{reflist}}

{{Authority control}}

{{DEFAULTSORT:Name-value pair}} [[Category:Data modeling]]