用于与json文件和对象交互的python实用程序
ctodd-python-lib-json的Python项目详细描述
christopher h.todd的python库,用于与json对象和文件进行交互
ctodd python lib json项目负责编写和读取json文件和对象。将处理将python对象编码为json。
目录
依赖关系
Python包
- SimpleJSON=3.16.0
库
json_reading_helpers.py
此库用于帮助完成读取.json文件的任务
功能:
def read_json_file_into_memory(json_file):
"""
Purpose:
Read properly formatted JSON file into memory.
Args:
json_file (String): Filename for JSON file to load (including path)
Returns:
json_object (Dictonary): Dictonary representation JSON Object
Examples:
>>> json_file = 'some/path/to/file.json'
>>> json_object = read_json_file_into_memory(json_file)
>>> print(json_object)
>>> {
>>> 'key': 'value'
>>> }
"""
json_writing_helpers.py
此库用于帮助完成读取.json文件的任务
功能:
def write_json_into_file(json_object, json_file):
"""
Purpose:
Load Dictionary into JSON File
Args:
json_object (Dictionary): Dictionary to be stored in .json format
json_file (String): Filename for JSON file to store (including path)
Returns:
N/A
Examples:
>>> json_file = 'some/path/to/file.json'
>>> json_object = {
>>> 'key': 'value'
>>> }
>>> write_json_into_file(json_file, json_object)
"""
示例脚本
用于测试和与库交互的示例可执行python脚本/模块。这些示例显示了库的用例,可以用作与库一起开发的模板,也可以用作一次性开发工作
不适用
注释
- 依赖于f-string符号,它仅限于python3.6。通过重构删除这些内容,可以使用python3.0.x到3.5.x进行开发
待办事项
- UnitTest框架已就位,但缺少测试