我能否在以下发言中发表一些意见?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如果有,如何处理?
当前回答
没有 No.
JSON 仅限数据。 如果您包含一个注释, 那么它也一定是数据 。
您可以使用指定数据元素"_comment"
使用JSON数据的应用程序应该忽略(或某事)这一点。
在产生/接收JSON的进程中,你最好有评论,因为他们应该知道JSON的数据会是什么,或者至少知道它的结构。
但如果你决定:
{
"_comment": "comment text goes here...",
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": ["GML", "XML"]
},
"GlossSee": "markup"
}
}
}
}
}
其他回答
JSON不支持评论,也从未打算用于需要评论的配置文件。
Hjson 是人类的配置文件格式。 放松语法, 减少错误, 更多评论 。
见见(hjson.github.io) (hjson. github. iio) (hjson. github.) (吉森. 吉图布. io)JavaScript、Java、Python、PHP、Rust、Go、Ruby、C++和C#图书馆的JavaScript、Java、Java、Java、Python、PHP、Rust、Go、Ruby、C++和C#图书馆。
这是"你能吗"问题。这里有一个问题,"是" "是"回答。
不,你不应该使用重复的物体成员 将侧导道数据塞进 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和JSON需要提出评论。至少可在.NET Core 中提供评论。JSON和牛顿软JSON 工作很顺利
{
// this is a comment for those who is ok with being different
"regular-json": "stuff"...
}
是的,你可以,但你的分析 可能会失败(没有标准)
要分析这些注释,您应该删除这些注释,或者通过手写,或者使用正则表达式:
它取代任何评论,例如:
/****
* Hey
*/
/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/
它取代任何评论,例如:
// Hey
/\/\/.*/
在JavaScript, 你可以做这样的事情:
jsonString = jsonString.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/, "").replace(/\/\/.*/,"")
var object = JSON.parse(jsonString);
我们正在使用strip-json-comments
支持我们的项目。 它支持一些东西,比如:
/*
* Description
*/
{
// rainbows
"unicorn": /* ❤ */ "cake"
}
简简npm install --save strip-json-comments
安装和使用它如下:
var strip_json_comments = require('strip-json-comments')
var json = '{/*rainbows*/"unicorn":"cake"}';
JSON.parse(strip_json_comments(json));
//=> {unicorn: 'cake'}
推荐文章
- 如何合并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:额外数据