JSON object as key in key-value pair

javascript, json, key, object

Solution

This is what ES6 `Map` is for, it allows to use an object as key:

var map = new Map();
var obj1 = {};
var obj2 = {}; // identical, but not the same

map.set(obj1, 'value');

map.get(obj1); // 'value'
map.get(obj2); // undefined

Demo (Firefox and IE 11): http://jsbin.com/ehIgEha/1/edit?js,console, browser support: http://kangax.github.io/compat-table/es6/#Map

Problem

I see this isn't possible (in JavaScript), would this be due to serialization for persistance? ActionScript3 does allow object instances as keys flash.utils.Dictionary Then again, string Id's would serve the same uniqueness purpose of the instance, right?

Original source