Template:Team:Amsterdam/maarten/methyltransferases
From 2012.igem.org
(Difference between revisions)
Line 1: | Line 1: | ||
+ | <!DOCTYPE html> | ||
<html> | <html> | ||
- | <script type= | + | <body> |
- | { | + | <h2>Create Object from JSON String</h2> |
- | "employees": [ | + | <p> |
- | { "firstName":"John" , "lastName":"Doe" }, | + | First Name: <span id="fname"></span><br /> |
- | { "firstName":"Anna" , "lastName":"Smith" }, | + | Last Name: <span id="lname"></span><br /> |
- | { "firstName":"Peter" , "lastName":"Jones" } | + | </p> |
- | ] | + | <script type="text/javascript"> |
- | + | var txt = '{"employees":[' + | |
+ | '{"firstName":"John","lastName":"Doe" },' + | ||
+ | '{"firstName":"Anna","lastName":"Smith" },' + | ||
+ | '{"firstName":"Peter","lastName":"Jones" }]}'; | ||
+ | |||
+ | var obj = eval ("(" + txt + ")"); | ||
+ | |||
+ | document.getElementById("fname").innerHTML=obj.employees[1].firstName | ||
+ | document.getElementById("lname").innerHTML=obj.employees[1].lastName | ||
</script> | </script> | ||
+ | </body> | ||
</html> | </html> |
Revision as of 21:54, 1 August 2012
<!DOCTYPE html>
Create Object from JSON String
First Name:
Last Name: