Skip to main content

Library for convert N-level dictionaries to one-level dictionaries

Project description

general-conversors

general-conversors is a library for convert N-level dictionaries to one-level dictionaries

GitHub license pypi version

Installation

Use the package manager pip to install general-conversors.

pip3 install general-conversors

Usage

To 1-Level dictionary

from conversor.dict import ToOneLevel

source = {
  'error': False,
  'result': {
    'executed': True,
    'payload': 'Hello world',
    'code': 200
  }
}

conversor = ToOneLevel(source=source)
result = conversor.convert()
print('Result:', result)
# Result: {'error': False, 'result.executed': True, 'result.payload': 'Hello world', 'result.code': 200}

To N-level level dictionary

from conversor.dict import ToMultiLevel

source = {
  'error': False,
  'result.executed': True,
  'result.payload': 'Hello world',
  'result.code': 200
}

conversor = ToMultiLevel(source=source)
result = conversor.convert()
print('Result:', result)
# Result: {'error': False, 'result': {'executed': True, 'payload': 'Hello world', 'code': 200}}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

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

general-conversors-1.0.2.tar.gz (2.7 kB view hashes)

Uploaded Source

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