I have a JSON array like below:
var jsonArray = [{\"k1\":\"v1\"},{\"k2\":\"v2\"},{\"k3\":\"v3\"},{\"k4\":\"v4\"},{\"k5\":\"v5\"}]
I don\'t
Try this:
jsonArray.reduce(function(keys, element){ for (key in element) { keys.push(key); } return keys; },[]);
This should also work for multiple keys in the array objects.
If you're supporting old browsers that don't have reduce and map, then consider using a shim.