Questions tagged [key-value]

A key-value pair is a set of two linked data items: a key which uniquely identifies some item of data, and the value, which is either the data that is identified or a pointer to the location of that data. Key-value pairs are frequently used in lookup tables, hash tables and configuration files.

A key-value pair is a set of two linked data items: a key which uniquely identifies some item of data, and the value, which is either the data that is identified or a pointer to the location of that data. Key-value pairs are frequently used in lookup tables, hash tables and configuration files.

http://searchenterprisedesktop.techtarget.com/definition/key-value-pair

A collection of key-value pairs is called an associative array.

The concept of key value pairs is applied in modern NoSQL databases for representing a storage mechanism. Key-Value is also a way to assign attributes and values to NSObject based instances in Cocoa framework (Related: Objective-C).

3201 questions
24
votes
5 answers

Best way to use a PostgreSQL database as a simple key value store

I am being required to use a postgreSQL database and it will replace my current use of berkeleyDB. Although; I realize this is not an ideal situation, it is beyond my control. So the question is... If you were required to make postgreSQL into a key…
dennisjtaylor
  • 996
  • 1
  • 8
  • 17
24
votes
6 answers

Finding already existing value in Key Value pair

I am storing a string and int value in Key value pair. var list = new List>(); While adding i need to check if string(Key) already exists in list, if exists i need to add it to Value instead of adding new key. How to…
Olivarsham
  • 1,701
  • 5
  • 25
  • 51
24
votes
2 answers

Mongo conditional for "key doesn't exist"?

I want to find a document using a conditional if the key == None or if the key doesn't exist. Something like this: myDoc = self.request.root.db.myDocs.find_one({ '$or': [ {'myKey' :…
zakdances
  • 22,285
  • 32
  • 102
  • 173
23
votes
4 answers

Create a Dictionary in xaml?

Pseudo example:
Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
23
votes
8 answers

How do you escape colon (:) in Properties file?

I am using a properties file to store my application's configuration values. In one of the instances, I have to store a value as xxx:yyy:zzz. When I do that, the colon is escaped with a back slash\ resulting in the value showing as xxx\:yyy\:zzz in…
indiws
  • 283
  • 1
  • 3
  • 6
22
votes
5 answers

Storing a Key Value Array into a compact JSON string

I want to store an array of key value items, a common way to do this could be something like: // the JSON data may store several data types, not just key value lists, // but, must be able to identify some data as a key value list // --> more…
umlcat
  • 4,091
  • 3
  • 19
  • 29
22
votes
5 answers

PHP - split String in Key/Value pairs

I have a string like this: key=value, key2=value2 and I would like to parse it into something like this: array( "key" => "value", "key2" => "value2" ) I could do something like $parts = explode(",", $string) $parts = array_map("trim",…
Sebastian Hoitz
  • 9,343
  • 13
  • 61
  • 77
21
votes
3 answers

How to remove hash keys which hash value is blank?

I am using Ruby on Rails 3.2.13 and I would like to remove hash keys which corresponding hash value is blank. That is, if I have the following hash { :a => 0, :b => 1, :c => true, :d => "", :e => " ", :f => nil } then the resulting hash should be…
user502052
  • 14,803
  • 30
  • 109
  • 188
21
votes
6 answers

Represent graph data as a key-value object

I'm starting to dig into graph databases, but i have no idea, how these graphs are stored internally. Let's say i have this graph (taken from Wikipedia): How do i serialize this graph as a key-value object? (a Python dict, for example) I imagine…
Mirzhan Irkegulov
  • 17,660
  • 12
  • 105
  • 166
20
votes
3 answers

Python - can a dict have a value that is a list?

When using Python is it possible that a dict can have a value that is a list? for example, a dictionary that would look like the following (see KeyName3's values): { keyName1 : value1, keyName2: value2, keyName3: {val1, val2, val3} } I already know…
Paul Kernaghan
  • 203
  • 1
  • 2
  • 5
20
votes
3 answers

Does Consul persist the Key Value store?

I'm evaluating a few distributed key-value stores, and etcd and Consul looks both very promising. I am interested in service discovery, health monitoring and config services. I like the extra features that Consul gives, but I cannot determine…
Pieter
  • 2,143
  • 3
  • 14
  • 13
19
votes
3 answers

When to use ":"(colon) operator in javascript vs "=" operator?

I tried looking online everywhere for past hour, but I can't seem to figure out when to use colon operator : vs = operator in javascript? From what I can tell so far, it seems when defining object properties use colon :.
Dave2345
  • 473
  • 2
  • 5
  • 14
19
votes
1 answer

Is there a way to represent an object of key-value pairs in GraphQL

I am using GraphQL in my Node.js application. And I want to store an object that uses keys as a locale short code and values for the string in the corresponding language. (like { en: "Hello", ru: "Привет" } etc.) I want to represent this using…
serge1peshcoff
  • 4,342
  • 11
  • 45
  • 76
18
votes
5 answers

PHP create key => value pairs within a foreach

I want to create a key-value pairs in an array within a foreach. Here is what I have so far: function createOfferUrlArray($Offer) { $offerArray = array(); foreach ($Offer as $key => $value) { $keyval = array($key => $value[4] ); …
BobFlemming
  • 2,040
  • 11
  • 43
  • 59
18
votes
2 answers

get data from dynamic key value in json

The requirement is following: I have to get the location field from page. var input= global.input = document.getElementById("Location"); Get the neighborhood area from the json file based on input and show on the page. I have a json object and have…
AutoMEta
  • 1,339
  • 6
  • 22
  • 35