How to create a Hashtable in javascript from a JSON by setting a value as the key? -


i apologize if vague, want search each json object unique value , spit out value. have been told idea create hash table issue, not know how go this. example:

{     "form_key" : "basicpatientname",     "data" : "miranda jones",     "cid" : 2,     "pid" : 1,     "no" : "0" } 

i want search basicpatientname , able pull miranda jones, or search basicpatientgender , pull 1.
used library called defiantjs lets me loop through json , lets me asking, have been told there many iterations involved if want 1000+ times in same program.

you use this:

data = [{      "form_key" : "basicpatientname",      "data" : "miranda jones",      "cid" : 2,      "pid" : 1,      "no" : "0"  },  {      "form_key" : "basicpatientgender",      "data" : "1",      "cid" : 4,      "pid" : 1,      "no" : "0"  }  ];    var result = {};  data.foreach(function (rec) {      result[rec.form_key] = rec.data;  });    // output result  console.log(result);    // example look-up use:  var data = result.basicpatientname; //  = miranda jones


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

python 3.x - PyQt5 - Signal : pyqtSignal no method connect -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)