Skip to content

Commit

Permalink
#181 added example of global_config (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
nr23 authored Jun 8, 2023
1 parent 3239a99 commit 09f43c6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -522,15 +522,15 @@ from dataclasses_json import dataclass_json, config
from datetime import date
from marshmallow import fields

dataclasses_json.cfg.global_config.encoders[date] = date.isoformat
dataclasses_json.cfg.global_config.decoders[date] = date.fromisoformat

@dataclass_json
@dataclass
class DataClassWithIsoDatetime:
created_at: date = field(
metadata=config(
encoder= date.isoformat,
decoder= date.fromisoformat,
mm_field= fields.DateTime(format='iso')
))
created_at: date
modified_at: date
accessed_at: date
```

As you can see, you can **override** or **extend** the default codecs by providing a "hook" via a
Expand Down

0 comments on commit 09f43c6

Please sign in to comment.