{"id":19577142,"url":"https://github.com/developerstoolbox/data-converter-package","last_synced_at":"2025-04-27T06:32:04.638Z","repository":{"id":242576016,"uuid":"808112737","full_name":"DevelopersToolbox/data-converter-package","owner":"DevelopersToolbox","description":"A data converter package to convert data between JSON, YAML and XML.","archived":false,"fork":false,"pushed_at":"2024-11-11T04:47:58.000Z","size":113,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-11-11T05:32:28.206Z","etag":null,"topics":["data-converter","json","wolfsoftware","xml","yaml"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DevelopersToolbox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":".github/CODEOWNERS","security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["WolfSoftware","TGWolf"]}},"created_at":"2024-05-30T12:09:42.000Z","updated_at":"2024-11-11T04:48:01.000Z","dependencies_parsed_at":"2024-06-10T05:41:07.407Z","dependency_job_id":"18859a34-d4fa-43a0-bc4e-7692cf385f44","html_url":"https://github.com/DevelopersToolbox/data-converter-package","commit_stats":null,"previous_names":["developerstoolbox/data-converter-package"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevelopersToolbox%2Fdata-converter-package","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevelopersToolbox%2Fdata-converter-package/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevelopersToolbox%2Fdata-converter-package/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevelopersToolbox%2Fdata-converter-package/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DevelopersToolbox","download_url":"https://codeload.github.com/DevelopersToolbox/data-converter-package/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224062795,"owners_count":17249291,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-converter","json","wolfsoftware","xml","yaml"],"created_at":"2024-11-11T07:04:42.575Z","updated_at":"2024-11-11T07:04:43.850Z","avatar_url":"https://github.com/DevelopersToolbox.png","language":"Python","readme":"\u003c!-- markdownlint-disable --\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/\"\u003e\n        \u003cimg src=\"https://cdn.wolfsoftware.com/assets/images/github/organisations/developerstoolbox/black-and-white-circle-256.png\" alt=\"DevelopersToolbox logo\" /\u003e\n    \u003c/a\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/data-converter-package/actions/workflows/cicd.yml\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/DevelopersToolbox/data-converter-package/cicd.yml?branch=master\u0026label=build%20status\u0026style=for-the-badge\" alt=\"Github Build Status\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/data-converter-package/blob/master/LICENSE.md\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/license/DevelopersToolbox/data-converter-package?color=blue\u0026label=License\u0026style=for-the-badge\" alt=\"License\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/data-converter-package\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/created-at/DevelopersToolbox/data-converter-package?color=blue\u0026label=Created\u0026style=for-the-badge\" alt=\"Created\"\u003e\n    \u003c/a\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/data-converter-package/releases/latest\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/v/release/DevelopersToolbox/data-converter-package?color=blue\u0026label=Latest%20Release\u0026style=for-the-badge\" alt=\"Release\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/data-converter-package/releases/latest\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/release-date/DevelopersToolbox/data-converter-package?color=blue\u0026label=Released\u0026style=for-the-badge\" alt=\"Released\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/data-converter-package/releases/latest\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/commits-since/DevelopersToolbox/data-converter-package/latest.svg?color=blue\u0026style=for-the-badge\" alt=\"Commits since release\"\u003e\n    \u003c/a\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/data-converter-package/blob/master/.github/CODE_OF_CONDUCT.md\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Code%20of%20Conduct-blue?style=for-the-badge\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/data-converter-package/blob/master/.github/CONTRIBUTING.md\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Contributing-blue?style=for-the-badge\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/data-converter-package/blob/master/.github/SECURITY.md\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Report%20Security%20Concern-blue?style=for-the-badge\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/data-converter-package/issues\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Get%20Support-blue?style=for-the-badge\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n## Overview\n\nThe `wolfsoftware.data-converter` module provides functionalities for converting data between JSON, XML, and YAML formats.\nIt includes methods to convert dictionaries to and from these formats, making it a versatile tool for data transformation in Python applications.\n\n## Installation\n\nFirst, install the package using pip:\n\n```bash\npip install wolfsoftware.data-converter\n```\n\n## Usage\n\n### Importing the Module\n\nTo use the `DataConverter` class, import it from the `wolfsoftware.data_converter` package:\n\n```python\nfrom wolfsoftware.data_converter import DataConverter, DataConverterError\n```\n\n### Initializing the DataConverter\n\nThe `DataConverter` class requires data and its type as parameters during initialization. Supported data types are `json`, `xml`, `dict`, and `yaml`.\n\n```python\n# JSON data example\njson_data = '{\"name\": \"John\", \"age\": 30}'\nconverter = DataConverter(json_data, data_type='json')\n\n# XML data example\nxml_data = '\u003cperson\u003e\u003cname\u003eJohn\u003c/name\u003e\u003cage\u003e30\u003c/age\u003e\u003c/person\u003e'\nconverter = DataConverter(xml_data, data_type='xml')\n\n# Dictionary data example\ndict_data = {'name': 'John', 'age': 30}\nconverter = DataConverter(dict_data, data_type='dict')\n\n# YAML data example\nyaml_data = 'name: John\\nage: 30\\n'\nconverter = DataConverter(yaml_data, data_type='yaml')\n```\n\n### Converting Data\n\n#### To JSON\n\nConvert the data to JSON format using the `to_json` method:\n\n```python\njson_output = converter.to_json()\nprint(json_output)\n```\n\n#### To XML\n\nConvert the data to XML format using the `to_xml` method:\n\n```python\nxml_output = converter.to_xml()\nprint(xml_output)\n```\n\n#### To YAML\n\nConvert the data to YAML format using the `to_yaml` method:\n\n```python\nyaml_output = converter.to_yaml()\nprint(yaml_output)\n```\n\n### Example Usage\n\nHere's a complete example demonstrating how to convert a dictionary to JSON, XML, and YAML formats:\n\n```python\nfrom wolfsoftware.data_converter import DataConverter, DataConverterError\n\n# Dictionary data\ndata = {'name': 'John', 'age': 30}\n\n# Initialize DataConverter\nconverter = DataConverter(data, data_type='dict')\n\n# Convert to JSON\njson_output = converter.to_json()\nprint(\"JSON Output:\")\nprint(json_output)\n\n# Convert to XML\nxml_output = converter.to_xml()\nprint(\"XML Output:\")\nprint(xml_output)\n\n# Convert to YAML\nyaml_output = converter.to_yaml()\nprint(\"YAML Output:\")\nprint(yaml_output)\n```\n\n### Handling Unsupported Data Types\n\nIf an unsupported data type is provided, a `DataConverterError` will be raised:\n\n```python\ntry:\n    converter = DataConverter(data, data_type='unsupported')\nexcept DataConverterError as e:\n    print(f\"Error: {e}\")\n```\n\n\u003cbr /\u003e\n\u003cp align=\"right\"\u003e\u003ca href=\"https://wolfsoftware.com/\"\u003e\u003cimg src=\"https://img.shields.io/badge/Created%20by%20Wolf%20on%20behalf%20of%20Wolf%20Software-blue?style=for-the-badge\" /\u003e\u003c/a\u003e\u003c/p\u003e\n","funding_links":["https://github.com/sponsors/WolfSoftware","https://github.com/sponsors/TGWolf"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeveloperstoolbox%2Fdata-converter-package","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeveloperstoolbox%2Fdata-converter-package","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeveloperstoolbox%2Fdata-converter-package/lists"}