PDA

View Full Version : PropertyGrid and JSON



alessandro
4 Sep 2010, 3:51 AM
Hello,
I have a json like this:


[{"k":"key1","v":"value1"},{"k":"key2","v":"value2"}]


I would like to populate a propertyGrid with that value, stripped of "k" and "v".

Something like this:

key1: value1
key2: value2

I'm unable to do that, i don't know very well javascript.

laurentParis
4 Sep 2010, 10:31 PM
var datas = [{"k":"key1","v":"value1"},{"k":"key2","v":"value2"}];

var o = {}, i;
for(i = 0; i < datas.length; i++) {
o[datas[i].k] = o[datas[i].v];
}
datas = o;