Metadata-Version: 2.1
Name: ooj
Version: 0.0.5
Summary: 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.
Home-page: https://github.com/KiryxaTechDev/ooj
Download-URL: https://github.com/KiryxaTechDev/ooj/archive/refs/tags/0.0.5.zip
Author: KiryxaTech
Author-email: kiryxatech@gmail.com
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.1
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Description-Content-Type: text/markdown
License-File: LICENSE

<div align="center">
    <picture>
        <source media="(prefers-color-scheme: dark)" srcset="doc/images/libDarkImage.png">
        <img src="./doc/images/libLightImage.png">
    </picture>

![PyPI](https://img.shields.io/pypi/v/ooj)
![PyPI - Downloads](https://img.shields.io/pypi/dm/ooj?color=green&label=downloads)
![Downloads last 6 month](https://static.pepy.tech/personalized-badge/ooj?period=total&units=international_system&left_color=grey&right_color=green&left_text=downloads%20last%206%20month)
![PyPI - License](https://img.shields.io/badge/license-Apache2.0-blue)
</div>

---

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:
```bash
pip install ooj
```

### On Linux/MacOS:
```bash
pip3 install ooj
```

## Usage
### Import library
```python
import ooj
```

### Working with JsonFile
#### Creating a JsonFile object
Create a `JsonFile` object:
```python
my_file = ooj.JsonFile('your/path/to/file.json')
```

#### Read and write
Read or write:
```python
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
```python
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
```python
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
```python
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
>>> }
```
