首页 > 代码库 > json转js对象

json转js对象

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <script type="text/javascript" src="scripts/jquery.js" ></script>
    <script type="text/javascript" >
    var str_json = {"name":"张三", "age":19}; 
  var oJSON = eval((+str_json+));
  function show(){
            alert(oJSON.name); //张三
        }
    </script>
    <body>
        <input onclick="show()" type="button" value="aaaa" />
    </body>
</html>

 

json转js对象