对于unicode码的转换

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
var arr=[
    {
        "city":"\\u5357\\u6d54\\u533a",
        "code":"330503",
        "id":"289",
        "initial":"N",
        "provincecode":"330000"
    },
    {
        "city":"\\u5fb7\\u6e05\\u53bf",
        "code":"330521",
        "id":"312",
        "initial":"D",
        "provincecode":"330000"
    },
    {
        "city":"\\u5434\\u5174\\u533a",
        "code":"330502",
        "id":"329",
        "initial":"W",
        "provincecode":"330000"
    },
    {
        "city":"\\u957f\\u5174\\u53bf",
        "code":"330522",
        "id":"333",
        "initial":"Z",
        "provincecode":"330000"
    },
    {
        "city":"\\u5b89\\u5409\\u53bf",
        "code":"330523",
        "id":"342",
        "initial":"A",
        "provincecode":"330000"
    }
]
    //循环
    for(var i=0;i<arr.length;i++){
        arr[i].city=unescape(arr[i].city.replace(/\\/g,"%"));
    }
   console.log(arr)
    // 得到对应的名字
</script>
</body>
</html>

原文发布于微信公众号 - 李才哥(liqi13695515224)

原文发表时间:2018-10-22

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券