JSON格式检查

我需要开发一个功能来检查JSON文件的格式(逐行)。例如:

{
     "Firmware": {
        "type": "File",
        "file": {
            "type": "firmware",
            "maxSize": "300"
        },
        "possibleFiles": {
            "headers": ["name", "os", "platform", "version", "base"],
            "uniqueConstraint": ["name"]
        }
}

这是有效的JSON,格式正确,因此需要true。

{
    "Firmware": {
        "type": "singleFile",
        "file": {
            "type": "firmware",
            "maxSize": "300000000"
        },"possibleFiles": {
            "headers": ["name", "os", "platform", "version", "base"],
            "uniqueConstraint": ["name"]
        }
 }

This is also valid JSON, but it has the wrong formatting of "},"possibleFiles": {". It's difficult to read and understand, so I need false here.

我该如何实现?

评论