wolfsoftware.data-converter

A data converter package to convert data between JSON, YAML and XML.

https://github.com/developerstoolbox/data-converter-package

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.8%) to scientific vocabulary

Keywords

data-converter json wolfsoftware xml yaml
Last synced: 10 months ago · JSON representation ·

Repository

A data converter package to convert data between JSON, YAML and XML.

Basic Info
  • Host: GitHub
  • Owner: DevelopersToolbox
  • License: mit
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 223 KB
Statistics
  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • Open Issues: 3
  • Releases: 3
Topics
data-converter json wolfsoftware xml yaml
Created about 2 years ago · Last pushed 11 months ago
Metadata Files
Readme Contributing Funding License Code of conduct Citation Codeowners Security

README.md

DevelopersToolbox logo
Github Build Status License Created
Release Released Commits since release

Overview

The wolfsoftware.data-converter module provides functionalities for converting data between JSON, XML, and YAML formats. It includes methods to convert dictionaries to and from these formats, making it a versatile tool for data transformation in Python applications.

Installation

First, install the package using pip:

bash pip install wolfsoftware.data-converter

Usage

Importing the Module

To use the DataConverter class, import it from the wolfsoftware.data_converter package:

python from wolfsoftware.data_converter import DataConverter, DataConverterError

Initializing the DataConverter

The DataConverter class requires data and its type as parameters during initialization. Supported data types are json, xml, dict, and yaml.

```python

JSON data example

jsondata = '{"name": "John", "age": 30}' converter = DataConverter(jsondata, data_type='json')

XML data example

xmldata = 'John30' converter = DataConverter(xmldata, data_type='xml')

Dictionary data example

dictdata = {'name': 'John', 'age': 30} converter = DataConverter(dictdata, data_type='dict')

YAML data example

yamldata = 'name: John\nage: 30\n' converter = DataConverter(yamldata, data_type='yaml') ```

Converting Data

To JSON

Convert the data to JSON format using the to_json method:

python json_output = converter.to_json() print(json_output)

To XML

Convert the data to XML format using the to_xml method:

python xml_output = converter.to_xml() print(xml_output)

To YAML

Convert the data to YAML format using the to_yaml method:

python yaml_output = converter.to_yaml() print(yaml_output)

Example Usage

Here's a complete example demonstrating how to convert a dictionary to JSON, XML, and YAML formats:

```python from wolfsoftware.data_converter import DataConverter, DataConverterError

Dictionary data

data = {'name': 'John', 'age': 30}

Initialize DataConverter

converter = DataConverter(data, data_type='dict')

Convert to JSON

jsonoutput = converter.tojson() print("JSON Output:") print(json_output)

Convert to XML

xmloutput = converter.toxml() print("XML Output:") print(xml_output)

Convert to YAML

yamloutput = converter.toyaml() print("YAML Output:") print(yaml_output) ```

Handling Unsupported Data Types

If an unsupported data type is provided, a DataConverterError will be raised:

python try: converter = DataConverter(data, data_type='unsupported') except DataConverterError as e: print(f"Error: {e}")


Owner

  • Name: Developers Toolbox
  • Login: DevelopersToolbox
  • Kind: organization
  • Email: github@wolfsoftware.com
  • Location: United Kingdom

A selection of tools to help developers. Created by Wolf Software.

Citation (CITATION.cff)

cff-version: 1.2.0
message: If you use this software, please cite it using these metadata.
title: Data Converter
abstract: A data converter package to convert data between JSON, YAML and XML.
type: software
version: 0.1.1
date-released: 2024-06-26
repository-code: https://github.com/DevelopersToolbox/data-converter-package
keywords:
  - "Wolf Software"
  - "Software"
license: MIT
authors:
  - family-names: "Wolf"
    orcid: "https://orcid.org/0009-0007-0983-2072"

GitHub Events

Total
  • Delete event: 77
  • Issue comment event: 163
  • Push event: 128
  • Pull request review event: 119
  • Pull request event: 154
  • Create event: 89
Last Year
  • Delete event: 77
  • Issue comment event: 163
  • Push event: 128
  • Pull request review event: 119
  • Pull request event: 154
  • Create event: 89

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 0
  • Total pull requests: 114
  • Average time to close issues: N/A
  • Average time to close pull requests: 4 days
  • Total issue authors: 0
  • Total pull request authors: 2
  • Average comments per issue: 0
  • Average comments per pull request: 1.79
  • Merged pull requests: 84
  • Bot issues: 0
  • Bot pull requests: 113
Past Year
  • Issues: 0
  • Pull requests: 84
  • Average time to close issues: N/A
  • Average time to close pull requests: 4 days
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 1.7
  • Merged pull requests: 59
  • Bot issues: 0
  • Bot pull requests: 84
Top Authors
Issue Authors
  • dependabot[bot] (3)
Pull Request Authors
  • dependabot[bot] (175)
  • TGWolf (1)
Top Labels
Issue Labels
dependabot: auto approve (3) dependabot: auto merge (3) dependabot: dependencies (3) dependabot: ecosystem : github actions (2) dependabot: ecosystem : python (1)
Pull Request Labels
dependabot: dependencies (175) dependabot: auto approve (137) dependabot: auto merge (136) dependabot: ecosystem : github actions (124) dependabot: ecosystem : python (51) dependabot: manual merge (24) resolution: closed (2) state: stale (2)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 13 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 2
  • Total maintainers: 1
pypi.org: wolfsoftware.data-converter

A data converter package to convert data between JSON, YAML and XML.

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 13 Last month
Rankings
Dependent packages count: 10.8%
Average: 35.9%
Dependent repos count: 61.0%
Maintainers (1)
Last synced: 11 months ago

Dependencies

.github/workflows/cicd.yml actions
  • ActionsToolbox/get-language-versions-action 446919617fd774095b5dd3ed71c39dd3fd0d8f4f composite
  • actions/checkout a5ac7e51b41094c92402da3b24376905380afc29 composite
  • actions/setup-python 82c7e631bb3cdc910f68e0081d67478d79c6982d composite
.github/workflows/citation-validation.yml actions
  • ActionsToolbox/get-language-versions-action 446919617fd774095b5dd3ed71c39dd3fd0d8f4f composite
  • actions/checkout a5ac7e51b41094c92402da3b24376905380afc29 composite
  • citation-file-format/cffconvert-github-action 4cf11baa70a673bfdf9dad0acc7ee33b3f4b6084 composite
  • ruby/setup-ruby 78c01b705fd9d5ad960d432d3a0cfa341d50e410 composite
.github/workflows/codeql.yml actions
  • Gamesight/slack-workflow-status 68bf00d0dbdbcb206c278399aa1ef6c14f74347a composite
  • actions/checkout a5ac7e51b41094c92402da3b24376905380afc29 composite
  • github/codeql-action/analyze a57c67b89589d2d13d5ac85a9fc4679c7539f94c composite
  • github/codeql-action/autobuild a57c67b89589d2d13d5ac85a9fc4679c7539f94c composite
  • github/codeql-action/init a57c67b89589d2d13d5ac85a9fc4679c7539f94c composite
.github/workflows/codeql.yml.old actions
  • Gamesight/slack-workflow-status 68bf00d0dbdbcb206c278399aa1ef6c14f74347a composite
  • actions/checkout a5ac7e51b41094c92402da3b24376905380afc29 composite
  • github/codeql-action/analyze a57c67b89589d2d13d5ac85a9fc4679c7539f94c composite
  • github/codeql-action/autobuild a57c67b89589d2d13d5ac85a9fc4679c7539f94c composite
  • github/codeql-action/init a57c67b89589d2d13d5ac85a9fc4679c7539f94c composite
.github/workflows/delete-old-workflow-runs.yml actions
  • Gamesight/slack-workflow-status 68bf00d0dbdbcb206c278399aa1ef6c14f74347a composite
  • Mattraks/delete-workflow-runs 39f0bbed25d76b34de5594dceab824811479e5de composite
.github/workflows/dependabot.yml actions
  • dependabot/fetch-metadata 5e5f99653a5b510e8555840e80cbf1514ad4af38 composite
.github/workflows/document-validation.yml actions
  • ActionsToolbox/get-language-versions-action 446919617fd774095b5dd3ed71c39dd3fd0d8f4f composite
  • actions/checkout a5ac7e51b41094c92402da3b24376905380afc29 composite
  • actions/setup-node 60edb5dd545a775178f52524783378180af0d1f8 composite
  • ruby/setup-ruby 78c01b705fd9d5ad960d432d3a0cfa341d50e410 composite
.github/workflows/generate-release.yml actions
  • ActionsToolbox/get-language-versions-action 446919617fd774095b5dd3ed71c39dd3fd0d8f4f composite
  • Bullrich/generate-release-changelog 6b60f004b4bf12ff271603dc32dbd261965ad2f2 composite
  • actions/checkout a5ac7e51b41094c92402da3b24376905380afc29 composite
  • actions/setup-python 82c7e631bb3cdc910f68e0081d67478d79c6982d composite
  • softprops/action-gh-release 69320dbe05506a9a39fc8ae11030b214ec2d1f87 composite
.github/workflows/generate-test-release.yml actions
  • ActionsToolbox/get-language-versions-action 446919617fd774095b5dd3ed71c39dd3fd0d8f4f composite
  • Bullrich/generate-release-changelog 6b60f004b4bf12ff271603dc32dbd261965ad2f2 composite
  • actions/checkout a5ac7e51b41094c92402da3b24376905380afc29 composite
  • actions/setup-python 82c7e631bb3cdc910f68e0081d67478d79c6982d composite
  • softprops/action-gh-release 69320dbe05506a9a39fc8ae11030b214ec2d1f87 composite
.github/workflows/greetings.yml actions
  • actions/first-interaction 34f15e814fe48ac9312ccf29db4e74fa767cbab7 composite
.github/workflows/purge-deprecated-workflow-runs.yml actions
  • Gamesight/slack-workflow-status 68bf00d0dbdbcb206c278399aa1ef6c14f74347a composite
  • otto-de/purge-deprecated-workflow-runs 31a4e821d43e9a354cbd65845922c76e4b4b3633 composite
.github/workflows/repository-validation.yml actions
  • ActionsToolbox/get-language-versions-action 446919617fd774095b5dd3ed71c39dd3fd0d8f4f composite
  • actions/checkout a5ac7e51b41094c92402da3b24376905380afc29 composite
  • actions/setup-go cdcb36043654635271a94b9a6d1392de5bb323a7 composite
  • actions/setup-python 82c7e631bb3cdc910f68e0081d67478d79c6982d composite
.github/workflows/security-hardening.yml actions
  • actions/checkout a5ac7e51b41094c92402da3b24376905380afc29 composite
  • zgosalvez/github-actions-ensure-sha-pinned-actions 76d1d8e0b075d7190b5d59b86da91c7bdbcc99b2 composite
.github/workflows/stale.yml actions
  • Gamesight/slack-workflow-status 68bf00d0dbdbcb206c278399aa1ef6c14f74347a composite
  • actions/stale 28ca1036281a5e5922ead5184a1bbf96e5fc984e composite
requirements.txt pypi
  • defusedxml ==0.7.1
  • pytest ==8.2.2
  • pyyaml ==6.0.1
  • setuptools ==70.0.0
setup.py pypi