Skip to main content

ASON: Adaptive Structure Object Notation - Python library for handling structured data with flexibility and ease.

Project description

ASON: Adaptive Structure Object Notation


Run Tests PyPI Version Python Versions Downloads Last Commit GitHub Issues GitHub Stars GitHub Forks

Maintainer Sponsor on GitHub License Stability

ASON is a Python library designed for adaptive data serialization. It seamlessly handles various data structures, offering flexibility and simplicity inspired by JSON.

Installation

pip install ason

Usage

# Usage example for Ason class

from ason import ason

# Create an Ason object
data = '{"name": "${name}", "age": ${age}, "city": "${city}", "hobbies": ["${hobby1}", "${hobby2}"]}'
ason_data = ason.loads(data)

# Set values for variables
ason_data.set("name", "John")
ason_data.set("age", 30)
ason_data.set("city", "New York")
ason_data.set("hobby1", "Reading")
ason_data.set("hobby2", "Coding")

# Print the result after setting variables
result_after_set = ason_data.dumps()
print("Result after setting variables:")
print(result_after_set)
print()

# Replace a key dynamically
ason_data.replace("age", "new_age", 25)

# Append a value to the 'hobbies' list
ason_data.append("hobbies", "Gardening")

# Print the result after replacing and appending
result_after_modify = ason_data.dumps()
print("Result after replacing and appending:")
print(result_after_modify)
print()

# Get the value associated with a key
city_value = ason_data.get("city")
print("Value for key 'city':", city_value)
print()

# Accessing values using square bracket notation
name_value = ason_data["name"]
print("Value for key 'name' using square bracket notation:", name_value)
print()

# Set a value using square bracket notation
ason_data["new_key"] = "new_value"
print("Result after setting a value using square bracket notation:")
print(ason_data.dumps())

This example demonstrates how to create an Ason object, load data, set values for variables, and then dump the result. The output will be a dictionary with the replaced values:

Result after setting variables:

{"name": "John", "age": "30", "city": "New York", "hobbies": ["${hobby1}", "${hobby2}"]}

Result after replacing and appending:

{"name": "John", "new_age": 25, "city": "New York", "hobbies": ["${hobby1}", "${hobby2}", "Gardening"]}

Value for key 'city': New York

Value for key 'name' using square bracket notation: John

Result after setting a value using square bracket notation:

{"name": "John", "new_age": 25, "city": "New York", "hobbies": ["${hobby1}", "${hobby2}", "Gardening"], "new_key": "new_value"}

Contributing

Contributions are welcome! Before contributing, please read our Contributing Guidelines to ensure a smooth and collaborative development process.

Code of Conduct

Please review our Code of Conduct to understand the standards of behavior we expect from contributors and users of this project.

License

This project is licensed under the Apache 2.0 License. See LICENSE for more details.

Support the Project


💰 You can help me improve more by offering a little support on any platform❤️

BuyMeACoffee Patreon Ko-Fi Sponsor muhammad-fiaz Open Collective Backer

Happy Coding ❤️

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

ason-0.0.1.tar.gz (10.6 kB view details)

Uploaded Source

File details

Details for the file ason-0.0.1.tar.gz.

File metadata

  • Download URL: ason-0.0.1.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for ason-0.0.1.tar.gz
Algorithm Hash digest
SHA256 fa0182429b39c6a34f7b11fad5d92d4831e6bbd9a12a3d85b6f7ccb85567c4cd
MD5 34c05c755835e4aaf8c1646c5fab79a6
BLAKE2b-256 55121ed6f59ce28c90997606a434dc01dc0c716323e03cad470f761cdd7f9c9a

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