Skip to content

Commit

Permalink
Update README and introduction
Browse files Browse the repository at this point in the history
  • Loading branch information
yukinarit committed Jun 10, 2024
1 parent 220b62f commit b6ad5bc
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<a href = "https://piptrends.com/package/pyserde" alt = "pyserde Downloads Last Month"><img alt="pyserde Downloads Last Month by pip Trends" src="https://assets.piptrends.com/get-last-month-downloads-badge/pyserde.svg"></a>
</p>
<p align="center">
<a href="https://yukinarit.github.io/pyserde/guide/en">Guide🇬🇧</a> | <a href="https://yukinarit.github.io/pyserde/guide/ja">ガイド🇯🇵</a> | <a href="https://yukinarit.github.io/pyserde/api/serde.html">API Docs</a> | <a href="https://github.com/yukinarit/pyserde/tree/main/examples">Examples</a>
<a href="https://yukinarit.github.io/pyserde/guide/en">Guide🇬🇧</a> | <a href="https://yukinarit.github.io/pyserde/guide/ja">ガイド🇯🇵</a> | <a href="https://yukinarit.github.io/pyserde/api/serde.html">API Reference</a> | <a href="https://github.com/yukinarit/pyserde/tree/main/examples">Examples</a>
</p>

## Overview
Expand Down
15 changes: 14 additions & 1 deletion docs/en/introduction.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Introduction

`pyserde` is a simple yet powerful serialization library on top of [dataclasses](https://docs.python.org/3/library/dataclasses.html). Simply adding pyserde's `@serde` decorator makes your class (de)serializable from/to many data formats.
`pyserde` is a simple yet powerful serialization library on top of [dataclasses](https://docs.python.org/3/library/dataclasses.html). It allows you to convert Python objects to and from JSON, YAML, and other formats easily and efficiently.

Declare your class with `@serde` decorator and annotate fields using [PEP484](https://peps.python.org/pep-0484/) as below.

```python
from serde import serde

@serde
class Foo:
i: int
Expand All @@ -14,12 +18,21 @@ class Foo:
You can serialize `Foo` object into JSON.

```python
>>> from serde.json import to_json
>>> to_json(Foo(i=10, s='foo', f=100.0, b=True))
'{"i":10,"s":"foo","f":100.0,"b":true}'
```

You can deserialize JSON into `Foo` object.
```python
>>> from serde.json import from_json
>>> from_json(Foo, '{"i": 10, "s": "foo", "f": 100.0, "b": true}')
Foo(i=10, s='foo', f=100.0, b=True)
```

## Next Steps

* [Getting started](getting-started.md)
* [API Reference](https://yukinarit.github.io/pyserde/api/serde.html)
* [Examples](https://github.com/yukinarit/pyserde/tree/main/examples)
* [FAQ](faq.md)
17 changes: 14 additions & 3 deletions docs/ja/introduction.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Introduction

`pyserde`[dataclasses](https://docs.python.org/3/library/dataclasses.html)ベースのシンプルで強力なシリアライゼーションライブラリです
`pyserde`[dataclasses](https://docs.python.org/3/library/dataclasses.html)ベースのシンプルで強力なシリアライゼーションライブラリで、クラスをJSONやYAML等の様々なデータフォーマットに簡単に効率的に変換可能になります

クラスに`@serde`デコレータを付けるだけで、クラスを様々なデータフォーマットに変換可能になります
クラスに`@serde`デコレータを付け、[PEP484](https://peps.python.org/pep-0484/)形式でフィールドに型アノテーションを付けます

```python
from serde import serde

@serde
class Foo:
i: int
Expand All @@ -13,15 +15,24 @@ class Foo:
b: bool
```

`Foo`クラスは以下のようにJSONにシリアライズ出来るようになります。
すると、`Foo`クラスは以下のようにJSONにシリアライズ出来るようになります。

```python
>>> from serde.json import to_json
>>> to_json(Foo(i=10, s='foo', f=100.0, b=True))
'{"i":10,"s":"foo","f":100.0,"b":true}'
```

また、JSONから`Foo`クラスにデシリアライズも出来るようになります。
```python
>>> from serde.json import from_json
>>> from_json(Foo, '{"i": 10, "s": "foo", "f": 100.0, "b": true}')
Foo(i=10, s='foo', f=100.0, b=True)
```

## Next Steps

* [Getting started](getting-started.md)
* [API Reference](https://yukinarit.github.io/pyserde/api/serde.html)
* [Examples](https://github.com/yukinarit/pyserde/tree/main/examples)
* [FAQ](faq.md)

0 comments on commit b6ad5bc

Please sign in to comment.