swiftserialize


Nameswiftserialize JSON
Version 1.0.1 PyPI version JSON
download
home_pageNone
SummaryA simple way to read and write structured data. Easily extendable to support custom data formats.
upload_time2025-02-03 20:11:31
maintainerNone
docs_urlNone
authorSean Yeatts
requires_python>=3.8
licenseMIT License
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            *Copyright (c) 2025 Sean Yeatts, Inc. All rights reserved.*

SwiftSerialize
==============

A simple way to read and write structured data. Easily extendable to support custom data formats.

Key Features
------------
- Easily read, write, and convert between structured data formats ( ex. json, yaml ).
- Provides convenience methods for de-nesting / re-nesting hierarchical datasets.
- Encode to binary for middleman services ( ex. data encryption ).


Quickstart
----------

**Example** - conversion between two structured data formats :

.. code:: python

  # IMPORTS
  from swiftserialize import JSONSerializer, YAMLSerializer


  # MAIN DEFINITION
  def main() -> None:

      # [1] Prepare some files
      file_1 = fr"cache\test.yaml"
      file_2 = fr"cache\test.json"

      # [2] Load structured data directly into a Python dict
      data: dict = YAMLSerializer().load(file_1)

      # [3] Convert to a different structured format
      JSONSerializer().save(data, file_2)


  # ENTRY POINT
  if __name__ == "__main__":
      main()


**Example** - introducing a middleman service :

.. code:: python

  # IMPORTS
  from swiftserialize import YAMLSerializer


  # MOCKUP FUNCTIONS
  def encrypt(data: bytes) -> bytes:
      """Placeholder encryption service."""
      return data


  # MAIN DEFINITION
  def main() -> None:

      # [1] Prepare some files
      file_1 = fr"cache\test.yaml"
      file_2 = fr"cache\test.bin"

      # [2] Convert to binary for middleman services ( ex. encryption )
      data        = YAMLSerializer().load(file_1)
      encoded     = YAMLSerializer().encode(data)
      encrypted   = encrypt(encoded)
      
      # [3] Serialize the modified data using the same serializer
      YAMLSerializer().serialize(encrypted, file_2)


  # ENTRY POINT
  if __name__ == "__main__":
      main()


**Example** - manipulating nested datasets :

.. code:: python

  # IMPORTS
  from swiftserialize import YAMLSerializer


  # MAIN DEFINITION
  def main() -> None:

      # [1] Prepare a file
      file = fr"cache\test.yaml"
      
      # [2] Nested datasets can be conveniently "unpacked" into single key-value pairs
      original:   dict = YAMLSerializer().load(file)
      unpacked:   dict = YAMLSerializer().unpack(file)

      # [3] Nesting operations can be done directly with Python dicts
      flattened:  dict = YAMLSerializer().flatten(original)
      folded:     dict = YAMLSerializer().fold(flattened)

      print(original)
      print(unpacked)
      print(flattened)
      print(folded)

      # [4] Keys for flattened datasets are represented as tuples
      value = flattened.get(('PARAMETER', 'SUB-PARAMETER'))
      print(value)


  # ENTRY POINT
  if __name__ == "__main__":
      main()


Installation
------------
**Prerequisites:**

- Python 3.8 or higher is recommended
- pip 24.0 or higher is recommended

**For a pip installation:**

Open a new Command Prompt. Run the following command:

.. code:: sh

  py -m pip install swiftserialize

**For a local installation:**

Extract the contents of this module to a safe location. Open a new terminal and navigate to the top level directory of your project. Run the following command:

.. code:: sh

  py -m pip install "DIRECTORY_HERE\swiftserialize\dist\swiftserialize-1.0.0.tar.gz"

- ``DIRECTORY_HERE`` should be replaced with the complete filepath to the folder where you saved the SwiftSerialize module contents.
- Depending on the release of SwiftSerialize you've chosen, you may have to change ``1.0.0`` to reflect your specific version.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "swiftserialize",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Sean Yeatts",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/10/fd/6ce2aa5c4bc6f7f866bf9fff5abe72eb8250db75eb14a1ba0e16bdae1f5f/swiftserialize-1.0.1.tar.gz",
    "platform": null,
    "description": "*Copyright (c) 2025 Sean Yeatts, Inc. All rights reserved.*\n\nSwiftSerialize\n==============\n\nA simple way to read and write structured data. Easily extendable to support custom data formats.\n\nKey Features\n------------\n- Easily read, write, and convert between structured data formats ( ex. json, yaml ).\n- Provides convenience methods for de-nesting / re-nesting hierarchical datasets.\n- Encode to binary for middleman services ( ex. data encryption ).\n\n\nQuickstart\n----------\n\n**Example** - conversion between two structured data formats :\n\n.. code:: python\n\n  # IMPORTS\n  from swiftserialize import JSONSerializer, YAMLSerializer\n\n\n  # MAIN DEFINITION\n  def main() -> None:\n\n      # [1] Prepare some files\n      file_1 = fr\"cache\\test.yaml\"\n      file_2 = fr\"cache\\test.json\"\n\n      # [2] Load structured data directly into a Python dict\n      data: dict = YAMLSerializer().load(file_1)\n\n      # [3] Convert to a different structured format\n      JSONSerializer().save(data, file_2)\n\n\n  # ENTRY POINT\n  if __name__ == \"__main__\":\n      main()\n\n\n**Example** - introducing a middleman service :\n\n.. code:: python\n\n  # IMPORTS\n  from swiftserialize import YAMLSerializer\n\n\n  # MOCKUP FUNCTIONS\n  def encrypt(data: bytes) -> bytes:\n      \"\"\"Placeholder encryption service.\"\"\"\n      return data\n\n\n  # MAIN DEFINITION\n  def main() -> None:\n\n      # [1] Prepare some files\n      file_1 = fr\"cache\\test.yaml\"\n      file_2 = fr\"cache\\test.bin\"\n\n      # [2] Convert to binary for middleman services ( ex. encryption )\n      data        = YAMLSerializer().load(file_1)\n      encoded     = YAMLSerializer().encode(data)\n      encrypted   = encrypt(encoded)\n      \n      # [3] Serialize the modified data using the same serializer\n      YAMLSerializer().serialize(encrypted, file_2)\n\n\n  # ENTRY POINT\n  if __name__ == \"__main__\":\n      main()\n\n\n**Example** - manipulating nested datasets :\n\n.. code:: python\n\n  # IMPORTS\n  from swiftserialize import YAMLSerializer\n\n\n  # MAIN DEFINITION\n  def main() -> None:\n\n      # [1] Prepare a file\n      file = fr\"cache\\test.yaml\"\n      \n      # [2] Nested datasets can be conveniently \"unpacked\" into single key-value pairs\n      original:   dict = YAMLSerializer().load(file)\n      unpacked:   dict = YAMLSerializer().unpack(file)\n\n      # [3] Nesting operations can be done directly with Python dicts\n      flattened:  dict = YAMLSerializer().flatten(original)\n      folded:     dict = YAMLSerializer().fold(flattened)\n\n      print(original)\n      print(unpacked)\n      print(flattened)\n      print(folded)\n\n      # [4] Keys for flattened datasets are represented as tuples\n      value = flattened.get(('PARAMETER', 'SUB-PARAMETER'))\n      print(value)\n\n\n  # ENTRY POINT\n  if __name__ == \"__main__\":\n      main()\n\n\nInstallation\n------------\n**Prerequisites:**\n\n- Python 3.8 or higher is recommended\n- pip 24.0 or higher is recommended\n\n**For a pip installation:**\n\nOpen a new Command Prompt. Run the following command:\n\n.. code:: sh\n\n  py -m pip install swiftserialize\n\n**For a local installation:**\n\nExtract the contents of this module to a safe location. Open a new terminal and navigate to the top level directory of your project. Run the following command:\n\n.. code:: sh\n\n  py -m pip install \"DIRECTORY_HERE\\swiftserialize\\dist\\swiftserialize-1.0.0.tar.gz\"\n\n- ``DIRECTORY_HERE`` should be replaced with the complete filepath to the folder where you saved the SwiftSerialize module contents.\n- Depending on the release of SwiftSerialize you've chosen, you may have to change ``1.0.0`` to reflect your specific version.\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "A simple way to read and write structured data. Easily extendable to support custom data formats.",
    "version": "1.0.1",
    "project_urls": {
        "Homepage": "https://github.com/SeanYeatts/swiftserialize"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f1ca03e0e666f5709ea09029bec13c380bd7924e4c4a23262e4e732cc80f6727",
                "md5": "31517370b07f3dd90f2e7225098926a7",
                "sha256": "00562a495e22ace2cc25daf1b7f66da824b6e461bff7bc792892f26e70a70083"
            },
            "downloads": -1,
            "filename": "swiftserialize-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "31517370b07f3dd90f2e7225098926a7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 5288,
            "upload_time": "2025-02-03T20:11:29",
            "upload_time_iso_8601": "2025-02-03T20:11:29.293510Z",
            "url": "https://files.pythonhosted.org/packages/f1/ca/03e0e666f5709ea09029bec13c380bd7924e4c4a23262e4e732cc80f6727/swiftserialize-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "10fd6ce2aa5c4bc6f7f866bf9fff5abe72eb8250db75eb14a1ba0e16bdae1f5f",
                "md5": "c7f33b428a120848237ab0483ee40dcf",
                "sha256": "61dc14542a8879925e2c2dac20899315bd10864ec150977dffe9753067aa2c12"
            },
            "downloads": -1,
            "filename": "swiftserialize-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "c7f33b428a120848237ab0483ee40dcf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 4427,
            "upload_time": "2025-02-03T20:11:31",
            "upload_time_iso_8601": "2025-02-03T20:11:31.044752Z",
            "url": "https://files.pythonhosted.org/packages/10/fd/6ce2aa5c4bc6f7f866bf9fff5abe72eb8250db75eb14a1ba0e16bdae1f5f/swiftserialize-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-03 20:11:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SeanYeatts",
    "github_project": "swiftserialize",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "swiftserialize"
}
        
Elapsed time: 0.38789s