我能否在以下发言中发表一些意见?Json Json (Json Json) (Json Json Json) (Json Json) Json Json (Json Json) Json (Json) Json (Json) Json (Json) Json (Json) Json (Json) Json (Json) Json(Json) Json (Json) Json (Json) Json(Json) Json (Json) Json如果有,如何处理?


当前回答

我只是为配置文件才看到这个 我不想用XML 数字或“ini”格式(没有等级,没有真正的标准,等等)或Java“Propertys”格式(如.ini)。

JSON可以做他们所能做的一切,但是它不那么多动词,更易为人读——在许多语言中,剖析器很容易,而且无处不在。它只是一棵数据树。但它只是一棵数据树。但是,用“默认”的配置等文件来记录“默认”的配置和类似内容往往是必要的。配置从来不是“完整的文档 ” , 而是需要时可以读取的保存数据树。

我想用得着"#": "comment"为了"活人"JSON

其他回答

这取决于你的JSON图书馆Json.NET支持 JavaScript 风格的评论,/* commment */.

见见另一个堆叠溢出问题.

将JSON项目切成部分... ...我添加了"不切实际的评论"的行:

{

"#############################" : "Part1",

"data1"             : "value1",
"data2"             : "value2",

"#############################" : "Part2",

"data4"             : "value3",
"data3"             : "value4"

}

JSON本身不允许评论。 推理是完全愚蠢的, 因为你可以使用JSON。本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身 本身提出评论,完全排除推理,在完全没有正当理由的情况下装入解析器数据空间精确同一结果和潜在问题,如:JSON档案,附有评论。

如果您试图在(使用)///* */#举例说 ) , 那么有些分析师会失败, 因为这严格地说不在JSON 的规格之内。 所以您应该从未这样做。

例如,这里,这里,这里,这里,我的图像处理系统已保存图像标记和一些基本格式化(注释)信息( 在底部) :

{
    "Notations": [
        {
            "anchorX": 333,
            "anchorY": 265,
            "areaMode": "Ellipse",
            "extentX": 356,
            "extentY": 294,
            "opacity": 0.5,
            "text": "Elliptical area on top",
            "textX": 333,
            "textY": 265,
            "title": "Notation 1"
        },
        {
            "anchorX": 87,
            "anchorY": 385,
            "areaMode": "Rectangle",
            "extentX": 109,
            "extentY": 412,
            "opacity": 0.5,
            "text": "Rect area\non bottom",
            "textX": 98,
            "textY": 385,
            "title": "Notation 2"
        },
        {
            "anchorX": 69,
            "anchorY": 104,
            "areaMode": "Polygon",
            "extentX": 102,
            "extentY": 136,
            "opacity": 0.5,
            "pointList": [
                {
                    "i": 0,
                    "x": 83,
                    "y": 104
                },
                {
                    "i": 1,
                    "x": 69,
                    "y": 136
                },
                {
                    "i": 2,
                    "x": 102,
                    "y": 132
                },
                {
                    "i": 3,
                    "x": 83,
                    "y": 104
                }
            ],
            "text": "Simple polygon",
            "textX": 85,
            "textY": 104,
            "title": "Notation 3"
        }
    ],
    "imageXW": 512,
    "imageYW": 512,
    "imageName": "lena_std.ato",
    "tinyDocs": {
        "c01": "JSON image notation data:",
        "c02": "-------------------------",
        "c03": "",
        "c04": "This data contains image notations and related area",
        "c05": "selection information that provides a means for an",
        "c06": "image gallery to display notations with elliptical,",
        "c07": "rectangular, polygonal or freehand area indications",
        "c08": "over an image displayed to a gallery visitor.",
        "c09": "",
        "c10": "X and Y positions are all in image space. The image",
        "c11": "resolution is given as imageXW and imageYW, which",
        "c12": "you use to scale the notation areas to their proper",
        "c13": "locations and sizes for your display of the image,",
        "c14": "regardless of scale.",
        "c15": "",
        "c16": "For Ellipses, anchor is the  center of the ellipse,",
        "c17": "and the extents are the X and Y radii respectively.",
        "c18": "",
        "c19": "For Rectangles, the anchor is the top left and the",
        "c20": "extents are the bottom right.",
        "c21": "",
        "c22": "For Freehand and Polygon area modes, the pointList",
        "c23": "contains a series of numbered XY points. If the area",
        "c24": "is closed, the last point will be the same as the",
        "c25": "first, so all you have to be concerned with is drawing",
        "c26": "lines between the points in the list. Anchor and extent",
        "c27": "are set to the top left and bottom right of the indicated",
        "c28": "region, and can be used as a simplistic rectangular",
        "c29": "detect for the mouse hover position over these types",
        "c30": "of areas.",
        "c31": "",
        "c32": "The textx and texty positions provide basic positioning",
        "c33": "information to help you locate the text information",
        "c34": "in a reasonable location associated with the area",
        "c35": "indication.",
        "c36": "",
        "c37": "Opacity is a value between 0 and 1, where .5 represents",
        "c38": "a 50% opaque backdrop and 1.0 represents a fully opaque",
        "c39": "backdrop. Recommendation is that regions be drawn",
        "c40": "only if the user hovers the pointer over the image,",
        "c41": "and that the text associated with the regions be drawn",
        "c42": "only if the user hovers the pointer over the indicated",
        "c43": "region."
    }
}

实际的答案:视觉工作室代码2019年的用户将使用“ jsonc” 扩展名 。

这是切合实际的,因为这是视觉演播室代码所认可的延伸,以表明“JSON与评论”,请在下面的评论中告诉我其他编辑/编辑的情况。

如果视觉演播室代码和其他编辑也会加入当地对JSON5的支持,

(我在张贴前搜索了所有答案,

这是"你能吗"问题。这里有一个问题,"是" "是"回答。

不,你不应该使用重复的物体成员 将侧导道数据塞进 JSON 编码中。 (见“ 对象中的名称应该是独特的 ” )二、《公约》在《公约》中).

是的,你可以插入注释周围杰逊你可以分析出来

但如果你想用一种方式 插入和提取任意的侧通道数据到一个有效的 JSON , 答案是这里。 我们利用 JSON 编码中的数据非独有的表达方式。 这允许 。*在RFC第二节“允许在六个结构字符中的任何字符之前或之后使用白色空间”。

*RFC 仅声明“ 允许在六个结构字符之前或之后使用白色空间”, 没有明确提及字符串、 数字、 “ false ”、“ true ” 和“ null ” 。 在所有执行中忽略了这一遗漏 。


首先,用简单化的方式 将你的JSON化为金字塔:

$jsonMin = json_encode(json_decode($json));

然后将您的评论编码为二进制 :

$hex = unpack('H*', $comment);
$commentBinary = base_convert($hex[1], 16, 2);

然后将您的二进制评分:

$steg = str_replace('0', ' ', $commentBinary);
$steg = str_replace('1', "\t", $steg);

以下是您的输出 :

$jsonWithComment = $steg . $jsonMin;