Skip to main content

SerialiJSON

serialiJSON is a tool that allows you to convert complex objects to JSON only by inheriting the BaseSerializable class.

Installation

python pip -m install serialiJSON

Usage

Import BaseSerializable class

from serialiJSON import BaseSerializable

Define your own class inheriting BaseSerializable

class myClass(BaseSerializable):
	...

myObject = myClass()

Convert to JSON

myObject.toJson()

An optional indent can be passed into toJson()

Property Description type default
indent set the indent to pretty-printed Int None (most compact)

Compatible Types

Type List mode
str [str]
int [int]
bool [bool]
float [float]

Real Example

from serialiJSON import BaseSerializable

class Item(BaseSerializable):
	def __init__(self, itemName, isAlive):
		self.itemName = itemName
		self.isAliva = isAlive

class Pet(BaseSerializable):
	def __init__(self, name, age, favItems):
		self.name = name
		self.age = age
		self.favItems = favItems

class Human(BaseSerializable):
	def __init__(self, name, age, pets):
		self.name = name
		self.age = age
		self.pets = pets

items = [
		Item("snow ball", False),
		Item("tree", True)
	]

pets = [
		Pet("Cat", 12, items), 
		Pet("Dog", 4, items)
	]

human = Human("name", 90, pets)

print(human.toJson(indent=4))

pretty-printed

{
	"name": "name",
	"age": 90,
	"pets": [
		{
			"name": "Cat",
			"age": 12,
			"favItems": [
				{
					"itemName": "snow ball",
					"isAliva": false
				},
				{
					"itemName": "tree",
					"isAliva": true
				}
			]
		},
		{
			"name": "Dog",
			"age": 4,
			"favItems": [
				{
					"itemName": "snow ball",
					"isAliva": false
				},
				{
					"itemName": "tree",
					"isAliva": true
				}
			]
		}
	]
}

non pretty-printed

{"name": "name", "age": 90, "pets": [{"name": "Cat", "age": 12, "favItems": [{"itemName": "snow ball", "isAliva": false}, {"itemName": "tree", "isAliva": true}]}, {"name": "Dog", "age": 4, "favItems": [{"itemName": "snow ball", "isAliva": false}, {"itemName": "tree", "isAliva": true}]}]}

Metadata

Release files for serialiJSON 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for serialiJSON 0.0.2
File Size Uploaded
serialiJSON-0.0.2.tar.gz 3.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for serialiJSON 0.0.2
File Interpreter ABI Platform
serialiJSON-0.0.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 6.9 kB

Release files / serialiJSON-0.0.2.tar.gz

Download URL serialiJSON-0.0.2.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e541644d0869f5f153627a5e0a5447026206f09211f968016d803837d4064f24
BLAKE2b-256 checksum
How to use checksums
090d4735f3d078972a7c1bf547118dd33136593bcbb811e477323e98fa467352
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / serialiJSON-0.0.2-py2.py3-none-any.whl

Download URL serialiJSON-0.0.2-py2.py3-none-any.whl
Size 3.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
652dd45a94daded23c83cdafd4fc15a2090e1a79a6b1d3f8dd6683a56878de74
BLAKE2b-256 checksum
How to use checksums
6928917927c9420dc1564479e9f25543ae44602e12da9a89562aa43c1acb8147
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page