我能否在以下发言中发表一些意见?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如果有,如何处理?
当前回答
如果您正在使用 NewtonSoft.Json 库和 ASP.NET 来读取/删除您在 JSON 内容中可以使用 :
/"名字": "字符串"
//“ id” : 整数
或
* 这是
注释示例 */
PS :单行评论仅以6+版本的牛顿软 Json 支持。
给那些无法思考的人的附加说明:我在一个 ASP.NET 网络应用程序中使用了用于基本设置的 JSON 格式。 我读了文件, 将其转换成设置对象, 与 Newtonoft 库一起使用, 必要时使用 。
我更喜欢在JSON档案中写关于每个设置的评论, 我真的不在乎JSON格式的完整性, 只要我使用的图书馆可以使用。
我认为这比创建单独的“ 设置. README” 文件并解释其中的设置更容易使用/ 理解” 。
如果你对这种用法有问题, 对不起, 精灵从灯里出来了。 人们会发现JSON格式的其他用法, 您对此无能为力 。
其他回答
你不行,至少这就是我的经验json.org.
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"
}
}
}
}
}
我喜欢 @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"
}
}
实际的答案:视觉工作室代码2019年的用户将使用“ jsonc” 扩展名 。
这是切合实际的,因为这是视觉演播室代码所认可的延伸,以表明“JSON与评论”,请在下面的评论中告诉我其他编辑/编辑的情况。
如果视觉演播室代码和其他编辑也会加入当地对JSON5的支持,
(我在张贴前搜索了所有答案,
如果您的上下文是 NOde.js 配置, 您可以考虑 JavaScript 通过module.exports
作为JSON的替代:
module.exports = {
"key": "value",
// And with comments!
"key2": "value2"
};
缩略require
语法将保持不变 。 作为 JavaScript, 文件扩展名应该是.js
.
推荐文章
- 在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#对象