weixin_33736649 2018-07-05 15:06 采纳率: 0%
浏览 106

Chrome扩展程序json文件

I'm using Chrome Extension to change a sites CSS/javascript.

I'm looking to manipulate the layout and get data.

Inspecting the code on the website I can see it has a json file, similar to the below:

< form id='preference' data-json={'name':'test','age':'40'},{'name':'test','age':'30'},{'name':'test','age':'50'} >

How would I loop through the information in the JSON file?

  • 写回答

1条回答 默认 最新

  • weixin_33721427 2018-07-05 15:36
    关注

    Suppose you have a JSON like this or you convert your data like the format below:

    var data =   [{
            "name": "test",
            "age": "40"
        }, {
            "name": "test",
            "age": "30"
        }, {
            "name": "test",
            "age": "20"
        }]
    

    As you are asking, how to loop through JSON. Follow this:

    data.forEach(function(d){
                    console.log("Name: " + d.name);
                    console.log("Age: " + d.age);
                });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 三极管电路求解,已知电阻电压和三级关放大倍数
  • ¥15 ADS时域 连续相位观察方法
  • ¥15 Opencv配置出错
  • ¥15 模电中二极管,三极管和电容的应用
  • ¥15 关于模型导入UNITY的.FBX: Check external application preferences.警告。
  • ¥15 气象网格数据与卫星轨道数据如何匹配
  • ¥100 java ee ssm项目 悬赏,感兴趣直接联系我
  • ¥15 微软账户问题不小心注销了好像
  • ¥15 x264库中预测模式字IPM、运动向量差MVD、量化后的DCT系数的位置
  • ¥15 curl 命令调用正常,程序调用报 java.net.ConnectException: connection refused