What exactly is a hash in regards to JSON?

A Hash is a sparse array that uses arbitrary strings/objects (depending on the implementation, this varies across programming languages) rather than plain integers as keys.

In Javascript, any Object is technically a hash (also referred to as a Dictionary, Associative-Array, etc).

Examples:

var myObj = {}; // Same as = new Object();
myObj['foo'] = 'bar';

var myArr = []; // Same as = new Array();
myArr[0] = 'foo';
myArr[1] = 'bar';
myArr['blah'] = 'baz'; // This will work, but is not recommended.

Now, since JSON is basically using JS constructs and some strict guidelines to define portable data, the equivalent to myObj above would be:

{ "foo" : "bar" };

Hope this helps.

Leave a Comment

techhipbettruvabetnorabahisbahis forumu