我能否在以下发言中发表一些意见?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如果有,如何处理?
当前回答
我喜欢 @eli ' s 方法, 超过 30 个答案, 但没有人提到列表( array) 。 所以使用 @eli ' s 方法, 我们可以做一些类似的事情:
"part_of_speech": {
"__comment": [
"@param {String} type - the following types can be used: ",
"NOUN, VERB, ADVERB, ADJECTIVE, PRONOUN, PREPOSITION",
"CONJUNCTION, INTERJECTION, NUMERAL, PARTICLE, PHRASE",
"@param {String} type_free_form - is optional, can be empty string",
"@param {String} description - is optional, can be empty string",
"@param {String} source - is optional, can be empty string"
],
"type": "NOUN",
"type_free_form": "noun",
"description": "",
"source": "https://google.com",
"noun_class": {
"__comment": [
"@param {String} noun_class - the following types can be used: ",
"1_class, 2_class, 3_class, 4_class, 5_class, 6_class"
],
"noun_class": "4_class"
}
}
其他回答
虽然有些分析者支持C++式的评论,但我使用的是JsonCpp 专案在这些例子中,有这样一个例子:
// Configuration options
{
// Default encoding for text
"encoding" : "UTF-8",
// Plug-ins loaded at start-up
"plug-ins" : [
"python",
"c++",
"ruby"
],
// Tab indent size
"indent" : { "length" : 3, "use_space": true }
}
jsonlint (jsonlint)无法验证这一点。 因此, 批注是解析器特定的扩展名, 而不是标准扩展名 。
另一个解析器是杰森5.
JSON 替代 JSON 的替代方案汤加.
另一种替代办法是:jjsonc 喷气管.
最新版本的最新版本nlohmann/json(日元)可选择支持忽略对解析的评论 。
如果您的文本文件, 即 JSON 字符串, 将会被某个程序读取, 使用 C 或 C++ 样式之前要删除 C 或 C+ 样式的注释会有多困难 ?
答复:这将是一个班轮。 如果您这样做, JSON 文件可以用作配置文件 。
特意将JSON的评论删除。
我删除了JSON的评论,因为我看到有人利用他们来维持分解指令,这种做法会破坏互操作性。 我知道,缺乏评论会让一些人感到悲哀,但不应该。
假设您正在使用 JSON 保存配置文件, 您想要对此进行注释 。 请继续插入您想要的所有评论 。 然后通过 JSMIN 管道将其传送给您的 JSON 分析员 。
是的 你可以在JSON档案里发表评论
{
"": "Location to post to",
"postUrl": "https://example.com/upload/",
"": "Username for basic auth",
"username": "joebloggs",
"": "Password for basic auth (note this is in clear, be sure to use HTTPS!",
"password": "bloejoggs"
}
批注只是描述一组代码或配置的目的的文本。 由于您可以在 JSON 中多次指定密钥, 您可以这样做。 它在方法上是正确的, 唯一的取舍是您在字典中会有一个空密钥, 并有一些垃圾值( 您可以修饰...) 。
我在很多年前就看到了这个问题 但我只是在一个我正在研究的项目里 看到了这样的事情 我觉得这是个非常干净的方法,享受吧!
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."
}
}
推荐文章
- 在ASP中设置Access-Control-Allow-OriginNet MVC -最简单的方法
- JWT vs cookie用于基于令牌的身份验证
- JQ:选择多个条件
- 什么是HTTP中的“406-不可接受的响应”?
- 有没有办法注释掉.ASPX页面中的标记?
- ASP。NET Core返回带有状态码的JSON
- 我如何添加环境变量启动。VSCode中的json
- PostgreSQL返回JSON数组的结果集?
- HTTP POST在Java中使用JSON
- 如何指定杰克逊只使用字段-最好是全局
- jQuery为ajax请求返回“parsererror”
- 检查Postgres JSON数组是否包含字符串
- 将bash变量传递给jq
- 在$.ajax()中将数组传递给ajax请求
- 转换JSON字符串到c#对象