With a single property this is fairly easy:
var jsonobj = { \"test\": \"ok\" } var propname = \"test\"; // Will alert \"ok\" alert(jsonobj[propname]); <
This works, but rather suckily uses eval so I'm not recommending it's use:
eval
var jsonobj = { "test": { "test2": "ok" } } var propname = "test.test2"; alert(eval("jsonobj." + propname));
Try it here: http://jsfiddle.net/TAgsU/