https://github.com/cliffxuan/mew
Mew: python dataclass serializer/deserializer 🐱
https://github.com/cliffxuan/mew
dataclasses json python3
Last synced: 6 months ago
JSON representation
Mew: python dataclass serializer/deserializer 🐱
- Host: GitHub
- URL: https://github.com/cliffxuan/mew
- Owner: cliffxuan
- Created: 2019-01-16T00:39:56.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-07-09T19:38:50.000Z (almost 2 years ago)
- Last Synced: 2025-09-11T05:08:14.563Z (10 months ago)
- Topics: dataclasses, json, python3
- Language: Python
- Homepage:
- Size: 1.26 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Mew: python dataclass serializer/deserializer
=============================================
[](https://travis-ci.org/cliffxuan/mew)
[](https://img.shields.io/pypi/pyversions/mew.svg)
[](https://badge.fury.io/py/mew)
[](https://codeclimate.com/github/cliffxuan/mew)
[](https://github.com/ambv/black)

``` {.sourceCode .python}
from dataclasses import dataclass
from enum import Enum
from typing import List
import mew
class Type(Enum):
normal = 'normal'
electric = 'electric'
fire = 'fire'
fighting = 'fighting'
water = 'water'
psychic = 'psychic'
@mew.serializable
@dataclass
class Pokemon:
name: str
pokedex: int
type: Type
abilities: List[str]
>>> pikachu = Pokemon('Pikachu', 25, Type.electric, ['static', 'lightning rod'])
>>> pikachu
Pokemon(name='Pikachu', pokedex=25, type=, abilities=['static', 'lightning rod'])
>>> pikachu.dumps()
'{"name": "Pikachu", "pokedex": 25, "type": "electric", "abilities": ["static", "lightning rod"]}'
>>> assert pikachu == Pokemon.loads(pikachu.dumps())
```