ClassJsonMapper


NameClassJsonMapper JSON
Version 0.1b1 PyPI version JSON
download
home_pagehttps://github.com/PYmili/ClassJsonMapper
SummaryClassJsonMapper 是一个易于使用的Python库,旨在简化JSON数据与类对象之间的映射和转换过程。通过自定义类方法,它使得处理JSON文件变得直观、安全且高效。
upload_time2024-02-05 13:13:30
maintainer
docs_urlNone
authorPYmili
requires_python
licenseMIT
keywords json mapping data serialization object mapping
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            当然可以,以下是一个示例的GitHub项目简介:

---

# ClassJsonMapper

[![GitHub license](https://img.shields.io/github/license/pymili/ClassJsonMapper)](LICENSE)
[![PyPI version](https://img.shields.io/pypi/v/classjsonmapper)](https://pypi.org/project/classjsonmapper/)
[![Documentation](https://readthedocs.org/projects/classjsonmapper/badge/?version=latest)](https://classjsonmapper.readthedocs.io/en/latest/)

**ClassJsonMapper** 是一个易于使用的Python库,旨在简化JSON数据与类对象之间的映射和转换过程。通过自定义类方法,它使得处理JSON文件变得直观、安全且高效。

### 特性
- **自动映射**:将JSON数据直接加载到自定义类实例中,并支持反向转换为JSON格式。
- **类型检查**:在解析和序列化过程中提供严格的类型检查,确保数据一致性。
- **错误处理**:封装了自定义异常类型,如`FilePathError`和`JsonFileError`,用于清晰地报告可能遇到的问题。
- **灵活性**:支持多种模式打开文件,以及创建不存在的文件功能。可以通过表达式,快速查询或更改json数据。
- **上下文管理器支持**:通过 `with` 语句轻松实现资源的自动管理和清理。

### 安装
```bash
pip install classjsonmapper
```

### 快速开始
```python
import time
import ClassJsonMapper


start = time.time()
with ClassJsonMapper.Mapper("test.json") as mapper:
    # print(mapper.read())
    # print(mapper.get("name"))
    # print(mapper.get("age"))
    # print(mapper.get("dict"))
    # print(mapper.get("dict.1"))
    # print(mapper.get("list"))
    # print(mapper.get("list.0"))
    # print(mapper.get("list.[0:2]"))
    # print(mapper.get("list")[0:2])
    print(mapper.set("age", 19))
    print(mapper.set("dict.1", "Python"))
    print(mapper.set("list.6.0.1", "Python!"))
    print(mapper.set("list.6.0.2", "Python!"))

    # print(mapper.get("wapPopAdvert.url"))
    # print(mapper.get("wapPopAdvert.background"))
    # print(mapper.get("topicData"))

    mapper.write()
end = time.time()
print(f"耗时: {end - start}")
```

访问官方文档以获取详细信息和更多使用示例:
https://?????

欢迎贡献代码、提出问题或提交建议,共同优化和完善此库!

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/PYmili/ClassJsonMapper",
    "name": "ClassJsonMapper",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "json,mapping,data serialization,object mapping",
    "author": "PYmili",
    "author_email": "mc2005wj@163.com",
    "download_url": "https://files.pythonhosted.org/packages/de/6b/9a74459e1dd7f0db6d35edea4be6667bc37f309f9b9e81198617385fb672/ClassJsonMapper-0.1b1.tar.gz",
    "platform": null,
    "description": "\u5f53\u7136\u53ef\u4ee5\uff0c\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u7684GitHub\u9879\u76ee\u7b80\u4ecb\uff1a\r\n\r\n---\r\n\r\n# ClassJsonMapper\r\n\r\n[![GitHub license](https://img.shields.io/github/license/pymili/ClassJsonMapper)](LICENSE)\r\n[![PyPI version](https://img.shields.io/pypi/v/classjsonmapper)](https://pypi.org/project/classjsonmapper/)\r\n[![Documentation](https://readthedocs.org/projects/classjsonmapper/badge/?version=latest)](https://classjsonmapper.readthedocs.io/en/latest/)\r\n\r\n**ClassJsonMapper** \u662f\u4e00\u4e2a\u6613\u4e8e\u4f7f\u7528\u7684Python\u5e93\uff0c\u65e8\u5728\u7b80\u5316JSON\u6570\u636e\u4e0e\u7c7b\u5bf9\u8c61\u4e4b\u95f4\u7684\u6620\u5c04\u548c\u8f6c\u6362\u8fc7\u7a0b\u3002\u901a\u8fc7\u81ea\u5b9a\u4e49\u7c7b\u65b9\u6cd5\uff0c\u5b83\u4f7f\u5f97\u5904\u7406JSON\u6587\u4ef6\u53d8\u5f97\u76f4\u89c2\u3001\u5b89\u5168\u4e14\u9ad8\u6548\u3002\r\n\r\n### \u7279\u6027\r\n- **\u81ea\u52a8\u6620\u5c04**\uff1a\u5c06JSON\u6570\u636e\u76f4\u63a5\u52a0\u8f7d\u5230\u81ea\u5b9a\u4e49\u7c7b\u5b9e\u4f8b\u4e2d\uff0c\u5e76\u652f\u6301\u53cd\u5411\u8f6c\u6362\u4e3aJSON\u683c\u5f0f\u3002\r\n- **\u7c7b\u578b\u68c0\u67e5**\uff1a\u5728\u89e3\u6790\u548c\u5e8f\u5217\u5316\u8fc7\u7a0b\u4e2d\u63d0\u4f9b\u4e25\u683c\u7684\u7c7b\u578b\u68c0\u67e5\uff0c\u786e\u4fdd\u6570\u636e\u4e00\u81f4\u6027\u3002\r\n- **\u9519\u8bef\u5904\u7406**\uff1a\u5c01\u88c5\u4e86\u81ea\u5b9a\u4e49\u5f02\u5e38\u7c7b\u578b\uff0c\u5982`FilePathError`\u548c`JsonFileError`\uff0c\u7528\u4e8e\u6e05\u6670\u5730\u62a5\u544a\u53ef\u80fd\u9047\u5230\u7684\u95ee\u9898\u3002\r\n- **\u7075\u6d3b\u6027**\uff1a\u652f\u6301\u591a\u79cd\u6a21\u5f0f\u6253\u5f00\u6587\u4ef6\uff0c\u4ee5\u53ca\u521b\u5efa\u4e0d\u5b58\u5728\u7684\u6587\u4ef6\u529f\u80fd\u3002\u53ef\u4ee5\u901a\u8fc7\u8868\u8fbe\u5f0f\uff0c\u5feb\u901f\u67e5\u8be2\u6216\u66f4\u6539json\u6570\u636e\u3002\r\n- **\u4e0a\u4e0b\u6587\u7ba1\u7406\u5668\u652f\u6301**\uff1a\u901a\u8fc7 `with` \u8bed\u53e5\u8f7b\u677e\u5b9e\u73b0\u8d44\u6e90\u7684\u81ea\u52a8\u7ba1\u7406\u548c\u6e05\u7406\u3002\r\n\r\n### \u5b89\u88c5\r\n```bash\r\npip install classjsonmapper\r\n```\r\n\r\n### \u5feb\u901f\u5f00\u59cb\r\n```python\r\nimport time\r\nimport ClassJsonMapper\r\n\r\n\r\nstart = time.time()\r\nwith ClassJsonMapper.Mapper(\"test.json\") as mapper:\r\n    # print(mapper.read())\r\n    # print(mapper.get(\"name\"))\r\n    # print(mapper.get(\"age\"))\r\n    # print(mapper.get(\"dict\"))\r\n    # print(mapper.get(\"dict.1\"))\r\n    # print(mapper.get(\"list\"))\r\n    # print(mapper.get(\"list.0\"))\r\n    # print(mapper.get(\"list.[0:2]\"))\r\n    # print(mapper.get(\"list\")[0:2])\r\n    print(mapper.set(\"age\", 19))\r\n    print(mapper.set(\"dict.1\", \"Python\"))\r\n    print(mapper.set(\"list.6.0.1\", \"Python!\"))\r\n    print(mapper.set(\"list.6.0.2\", \"Python!\"))\r\n\r\n    # print(mapper.get(\"wapPopAdvert.url\"))\r\n    # print(mapper.get(\"wapPopAdvert.background\"))\r\n    # print(mapper.get(\"topicData\"))\r\n\r\n    mapper.write()\r\nend = time.time()\r\nprint(f\"\u8017\u65f6: {end - start}\")\r\n```\r\n\r\n\u8bbf\u95ee\u5b98\u65b9\u6587\u6863\u4ee5\u83b7\u53d6\u8be6\u7ec6\u4fe1\u606f\u548c\u66f4\u591a\u4f7f\u7528\u793a\u4f8b\uff1a\r\nhttps://?????\r\n\r\n\u6b22\u8fce\u8d21\u732e\u4ee3\u7801\u3001\u63d0\u51fa\u95ee\u9898\u6216\u63d0\u4ea4\u5efa\u8bae\uff0c\u5171\u540c\u4f18\u5316\u548c\u5b8c\u5584\u6b64\u5e93\uff01\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "ClassJsonMapper \u662f\u4e00\u4e2a\u6613\u4e8e\u4f7f\u7528\u7684Python\u5e93\uff0c\u65e8\u5728\u7b80\u5316JSON\u6570\u636e\u4e0e\u7c7b\u5bf9\u8c61\u4e4b\u95f4\u7684\u6620\u5c04\u548c\u8f6c\u6362\u8fc7\u7a0b\u3002\u901a\u8fc7\u81ea\u5b9a\u4e49\u7c7b\u65b9\u6cd5\uff0c\u5b83\u4f7f\u5f97\u5904\u7406JSON\u6587\u4ef6\u53d8\u5f97\u76f4\u89c2\u3001\u5b89\u5168\u4e14\u9ad8\u6548\u3002",
    "version": "0.1b1",
    "project_urls": {
        "Homepage": "https://github.com/PYmili/ClassJsonMapper"
    },
    "split_keywords": [
        "json",
        "mapping",
        "data serialization",
        "object mapping"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1338f260d1285a7ee25b585d6bce40a854d8f0e79e9e9b8609c681a8a4e0d095",
                "md5": "5f4ec7a2482da7097160b38d67a201d2",
                "sha256": "0fe5fc8a6fd8d58756ba1d042274e2c3259e79879f629d39e39719f94c4445f9"
            },
            "downloads": -1,
            "filename": "ClassJsonMapper-0.1b1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5f4ec7a2482da7097160b38d67a201d2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 6905,
            "upload_time": "2024-02-05T13:13:28",
            "upload_time_iso_8601": "2024-02-05T13:13:28.404171Z",
            "url": "https://files.pythonhosted.org/packages/13/38/f260d1285a7ee25b585d6bce40a854d8f0e79e9e9b8609c681a8a4e0d095/ClassJsonMapper-0.1b1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "de6b9a74459e1dd7f0db6d35edea4be6667bc37f309f9b9e81198617385fb672",
                "md5": "7750d4d08de06249716c0f5512671773",
                "sha256": "4de1582dd9b9f8beb2fa5f3565be60307894421c4af1b7c4c2f6092e509e0453"
            },
            "downloads": -1,
            "filename": "ClassJsonMapper-0.1b1.tar.gz",
            "has_sig": false,
            "md5_digest": "7750d4d08de06249716c0f5512671773",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6584,
            "upload_time": "2024-02-05T13:13:30",
            "upload_time_iso_8601": "2024-02-05T13:13:30.962165Z",
            "url": "https://files.pythonhosted.org/packages/de/6b/9a74459e1dd7f0db6d35edea4be6667bc37f309f9b9e81198617385fb672/ClassJsonMapper-0.1b1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-05 13:13:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "PYmili",
    "github_project": "ClassJsonMapper",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "classjsonmapper"
}
        
Elapsed time: 0.20458s