如何改善原始JSON数据以使用它?

时间:2018-10-08 17:54:42

标签: json

我正在尝试使用以“混合内容扫描”脚本的JSON格式导出的一些结果(该脚本是为了在网站上搜索是否存在一些HTTP / HTTPS混合内容并且您的所有页面都正常的脚本)在HTTPS中)。

我是JSON的初学者,我阅读并观看了许多教程,以了解如何构造JSON数据,但是我在某些方面遇到了困难。

以下是我的数据示例(前3行):

{"message":"Scanning https://mywebsite.com/","context":[],"level":250,"level_name":"NOTICE","channel":"MCS","datetime":{"date":"2018-10-05 23:48:50.268196","timezone_type":3,"timezone":"America/New_York"},"extra":[]}
{"message":"00000 - https://mywebsite.com/","context":[],"level":400,"level_name":"ERROR","channel":"MCS","datetime":{"date":"2018-10-05 23:48:50.760948","timezone_type":3,"timezone":"America/New_York"},"extra":[]}
{"message":"http://mywebsite.com/wp-content/uploads/2015/03/image.jpg","context":[],"level":300,"level_name":"WARNING","channel":"MCS","datetime":{"date":"2018-10-05 23:48:50.761082","timezone_type":3,"timezone":"America/New_York"},"extra":[]}

我知道我需要将数据包装在{}或[](都尝试过)的周围,但是我认为我丢失了一些东西,例如,每个JSON数据验证器网站都告诉我2之间存在错误当我尝试在其中添加多个结果时,会在每行中添加一行。

如何升级此原始数据,以便JSON验证器对其进行验证?

谢谢!

1 个答案:

答案 0 :(得分:0)

这怎么样

[{
    "message": "Scanning https://mywebsite.com/",
    "context": [],
    "level": 250,
    "level_name": "NOTICE",
    "channel": "MCS",
    "datetime": {
        "date": "2018-10-05 23:48:50.268196",
        "timezone_type": 3,
        "timezone": "America/New_York"
    },
    "extra": []
}, {
    "message": "00000 - https://mywebsite.com/",
    "context": [],
    "level": 400,
    "level_name": "ERROR",
    "channel": "MCS",
    "datetime": {
        "date": "2018-10-05 23:48:50.760948",
        "timezone_type": 3,
        "timezone": "America/New_York"
    },
    "extra": []
}, {
    "message": "http://mywebsite.com/wp-content/uploads/2015/03/image.jpg",
    "context": [],
    "level": 300,
    "level_name": "WARNING",
    "channel": "MCS",
    "datetime": {
        "date": "2018-10-05 23:48:50.761082",
        "timezone_type": 3,
        "timezone": "America/New_York"
    },
    "extra": []
}]

数组中的条目需要用逗号分隔。