Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
<h2>Create Object from JSON String</h2>
<p id="demo"></p>
</body>
</html>
 
var text = '{ "zipcodes": [     {        "zip": "22312",        "city": "Alexandria",        "state": "VA"  },    {        "zip": "22030",        "city": "Fairfax",        "state": "VA"    },    {        "zip": "22301",        "city": "Tyson\'s Corner",        "state": "VA"    },    {        "zip": "20148",        "city":"Ashburn",        "state": "VA"    }]}';
obj = JSON.parse(text);
document.getElementById("demo").innerHTML =
obj.zipcodes[1].zip + " " + obj.zipcodes[1].city;
console.log(obj);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
whoacowboypro
0viewers