Skip to main content

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

Project description

当然可以,以下是一个示例的GitHub项目简介:


ClassJsonMapper

GitHub license PyPI version Documentation

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

特性

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

安装

pip install classjsonmapper

快速开始

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://?????

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ClassJsonMapper-0.1b1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

ClassJsonMapper-0.1b1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file ClassJsonMapper-0.1b1.tar.gz.

File metadata

  • Download URL: ClassJsonMapper-0.1b1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for ClassJsonMapper-0.1b1.tar.gz
Algorithm Hash digest
SHA256 4de1582dd9b9f8beb2fa5f3565be60307894421c4af1b7c4c2f6092e509e0453
MD5 7750d4d08de06249716c0f5512671773
BLAKE2b-256 de6b9a74459e1dd7f0db6d35edea4be6667bc37f309f9b9e81198617385fb672

See more details on using hashes here.

File details

Details for the file ClassJsonMapper-0.1b1-py3-none-any.whl.

File metadata

File hashes

Hashes for ClassJsonMapper-0.1b1-py3-none-any.whl
Algorithm Hash digest
SHA256 0fe5fc8a6fd8d58756ba1d042274e2c3259e79879f629d39e39719f94c4445f9
MD5 5f4ec7a2482da7097160b38d67a201d2
BLAKE2b-256 1338f260d1285a7ee25b585d6bce40a854d8f0e79e9e9b8609c681a8a4e0d095

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page