A simple library to serialize and deserialize protobuf messages
Project description
Protolizer Documentation
Introduction
Protolizer is a simple library to serialize and deserialize protobuf messages
Installation
pip install protolizer
Usage for serialization
from protolizer import Serializer, fields
class AccountSerializer(Serializer):
username = fields.CharField()
balance = fields.IntField()
class Meta:
# Here we define our generated protobuf message name
# our protobuf message is something like:
# message Account {
# string username = 1;
# int32 balance = 2;
# }
schema = Account
# Define an account in JSON and Protobuf format
protobuf_data = Account(username='John', balance=100)
json_data = {'username': 'John', 'balance': 100}
# Serialize the data to Protobuf format
protobuf_serializer = AccountSerializer(protobuf_data)
print(protobuf_serializer.protobuf)
# Serialize the data to JSON format
json_serializer = AccountSerializer(json_data)
print(json_serializer.json)
# Deserialize the data from Protobuf format to JSON format
protobuf_deserializer = AccountSerializer(protobuf_serializer.protobuf)
print(protobuf_deserializer.data)
# Deserialize the data from JSON format to Protobuf format
json_deserializer = AccountSerializer(json_serializer.json)
print(json_deserializer.data)
Contribute
If you want to contribute to this project, please open an issue on GitHub.
License
This project is licensed under the MIT License.
Author
This project is authored by @uwsgi
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
protolizer-1.1.1.tar.gz
(12.5 kB
view details)
File details
Details for the file protolizer-1.1.1.tar.gz
.
File metadata
- Download URL: protolizer-1.1.1.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff5d170324fcebacf94f5f43c8466b0d9c2e34eeb4d600d6565115ac02b5755d |
|
MD5 | 20d4e8906b486e7fe95e06b438c5d2b1 |
|
BLAKE2b-256 | 0d77a0ba9b523a92cb1fa0fc18ac6eacca724491e820c000de0491027a8b3621 |