Skip to main content

OOJ (Object Oriented JSON) is a Python library designed to simplify working with JSON data. It allows you to create, process, and interact with JSON data using an object-oriented approach.

Project description

PyPI PyPI - Downloads Downloads last 6 month PyPI - License


The OOJ library is a Python package that simplifies working with JSON files. It provides methods to read, write, add, remove, and replace elements in a JSON file.

Installation

You can install the OOJ library directly from PyPI:

On Windows:

pip install ooj

On Linux/MacOS:

pip3 install ooj

Usage

Import library

import ooj

Working with JsonFile

Creating a JsonFile object

Create a JsonFile object:

my_file = ooj.JsonFile('your/path/to/file.json')

Read and write

Read or write:

data = {
 "name": "Jane",
 "age": 22,
 "is_happy": True
}

my_file.write(data)

print(my_file.read())

PS:
>>> {
>>>     "name": "Jane",
>>>     "age": 22,
>>>     "is_happy": True
>>> }

Sampling

data = {
 "1": -7,
 "2": 3,
 "3": 9
}

my_file.write(data)
selected_keys_dict = my_file.select(range(0, 10))
print(selected_keys_dict)

PS:
>>> {"2": 3, "3": 9}

Create serialization

You can serialize and deserialize objects.

Creating a serializer

from ooj import JsonSerializer
from ooj.excptions import NotSerializableError

# Options for serialization
options = {
    "indent": 4,
    "ignore_errors": NotSerializableError
}

serializer = JsonSerializer(options=options)

Serialize the object

class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age

serialized_person = serializer.serialize(Person("Mike", 29))
print(serialized_person)

PS:
>>> {
>>>     'name': 'Mike',
>>>     'age': 29
>>> }

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

ooj-0.0.4.tar.gz (12.1 kB view details)

Uploaded Source

File details

Details for the file ooj-0.0.4.tar.gz.

File metadata

  • Download URL: ooj-0.0.4.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for ooj-0.0.4.tar.gz
Algorithm Hash digest
SHA256 ef28ed31bc6499cc6d4cc57687811486c84e7b9cfc5ce690528e81fe2c48d568
MD5 1763187500e1ef72b75eb84284c3bd76
BLAKE2b-256 aa5f25444aca5d6d8e926a535af3a0470604657405678954b51b25dfe07a0ce7

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