json 注释

一、背景

今天聊个小东西,Json的的的注释。Json十分常见,大家用的很多,在语法上,规范的Json要求,文件里不可以写注释。原因呢,我调查了一下:

I removed comments from JSON because I saw people were using them to holdparsing directives, a practice which would have destroyed interoperability. I knowthat the lackl of comments makes some people sad, but it shouldn't.
原因是作者看到许多人使用注释来控制Json的解析,所以将它除掉了。
在Sofa-rpc开源框架里使用了宽泛的Json(带有注释),挺有意思,记录一下,以后一定要用带有注释的Json的话,可以参照。

二、使用
使用的方法请下载sofa-rpc(蚂蚁金服项目)源码,RpcConfigs.java文件中init()方法,注释//loadDefault部分 就是使用的例子。有兴趣的可以去看看。
sofa-rpc源码:
https://github.com/sofastack/sofa-rpc
原文地址:https://www.cnblogs.com/lihao007/p/11340847.html