我能否在以下发言中发表一些意见?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如果有,如何处理?
当前回答
虽然有些分析者支持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支持意见。
例如(样本样本样本瑞微软)
{
"Logging": {
"LogLevel": { // All providers, LogLevel applies to all the enabled providers.
"Default": "Error", // Default logging, Error and higher.
"Microsoft": "Warning" // All Microsoft* categories, Warning and higher.
},
"Debug": { // Debug provider.
"LogLevel": {
"Default": "Information", // Overrides preceding LogLevel:Default setting.
"Microsoft.Hosting": "Trace" // Debug:Microsoft.Hosting category.
}
},
"EventSource": { // EventSource provider
"LogLevel": {
"Default": "Warning" // All categories of EventSource provider.
}
}
}
}
这是"你能吗"问题。这里有一个问题,"是" "是"回答。
不,你不应该使用重复的物体成员 将侧导道数据塞进 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;
json speces 不支持评论, 但是您可以用键来写评论来解决这个问题, 像这样 。
{
"// my own comment goes here":"",
"key1":"value 1",
"// another comment goes here":"",
"key 2": "value 2 here"
}
我们使用评论文本作为关键, 以确保它们( 几乎) 是独一无二的, 它们不会打破任何解析器。 如果有些评论不是独一无二的, 请在结尾处添加随机数字 。
如果您需要分析任何处理中的评论, 比如剥除这些评论, 您可以用文字填充注释值, 表示它是一个注释 , 比如 :
{
"// my own comment goes here" : "_comment",
"key1":"value 1",
"// another comment goes here" : "_comment",
"key 2": "value 2 here"
}
以此方式, 分析者可以找到所有的评论并处理它们 。
Dojo工具包 JavaScript工具包(至少是1.4版)允许您在 JSON 中加入评论。/* */
Dojo 工具包使用JSONdojo.xhrGet()
拨打。
其他JavaScript工具箱也可能同样发挥作用。
在选择最后选择之前先试验其他数据结构(甚至数据清单)时,这样做会有帮助。
推荐文章
- 如何合并2 JSON对象从2个文件使用jq?
- 在VS Code中禁用“Comments are not allowed In JSON”错误
- 如何在Kotlin解析JSON ?
- JSON文件的蒙古导入
- 如何用jQuery / JavaScript解析JSON数据?
- jQuery在请求体中发布有效的json
- 将JSON显示为HTML
- Swift:理解// MARK
- 在JSON键名中哪些字符是有效的/无效的?
- 如何JSON序列化集?
- 如何检查JSON键是否存在?
- 在构建中编写注释的语法是什么?gradle文件?
- 将对象序列化为JSON
- node.js TypeError:路径必须是绝对路径或指定根路径到res.sendFile[解析JSON失败]
- Python json。loads显示ValueError:额外数据