在json文件中添加python和javascript风格的注释。
commentjson的Python项目详细描述
comment json(comment json)是一个帮助您创建json的python包 带有python和javascript风格内联注释的文件。它的api非常相似 到python标准库的json模块。
安装
pip install commentjson
基本用法
>>>importcommentjson>>>>>>json_string="""{ ... "name": "Vaidik Kapoor", # Person's name ... "location": "Delhi, India", // Person's location ... ... # Section contains info about ... // person's appearance ... "appearance": { ... "hair_color": "black", ... "eyes_color": "black", ... "height": "6" ... } ... }""">>>>>>json_loaded=commentjson.loads(json_string)>>>printjson_loaded{u'appearance':{u'eyes_color':u'black',u'hair_color':u'black',u'height':u'6'},u'name':u'Vaidik Kapoor',u'location':u'Delhi, India'}
文件
完整的文档可以找到here。
测试
python setup.py test