Skip to content

Instantly share code, notes, and snippets.

@troyscott
Created July 8, 2013 06:21
Show Gist options
  • Select an option

  • Save troyscott/5946597 to your computer and use it in GitHub Desktop.

Select an option

Save troyscott/5946597 to your computer and use it in GitHub Desktop.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>JSON - Adding Objects</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="generator" content="Geany 1.23" />
<script>
// array[element][key]
var cmds = [{say:"arg1, arg2"}, {dial:"arg1, arg2"}];
console.log(cmds);
console.log(cmds[0]['say']);
console.log(cmds[1]['dial']);
cmds.push({redirect:'arg1'});
console.log(cmds[2]['redirect']);
console.log("loop it");
for(i=0;i<cmds.length;i++)
{
for (x in cmds[i])
{
console.log(cmds[i][x]);
}
}
</script>
</head>
<body>
ok
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment