{"title":"datacalsses\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u542b\u3093\u3060\u5024\u3092JSON\u306b\u3059\u308b\u3068\u304d\u306e\u30e1\u30e2","image_url":null,"provider_name":"Hatena Blog","provider_url":"https://hatena.blog","author_name":"podhmo","author_url":"https://blog.hatena.ne.jp/podhmo/","width":"100%","categories":["python","dataclasses","json","singledispatch"],"description":"\u3044\u3064\u3082\u306e\u3084\u3064\u3067\u3059\u3002\u5bfe\u5fdc\u3057\u3066\u3044\u306a\u3044\u5024\u3092json.dumps()\u306b\u4e0e\u3048\u308b\u3068TypeError\u304c\u767a\u751f\u3059\u308b\u3084\u3064\u3067\u3059\u3002 TypeError \u4f8b\u3048\u3070\u3053\u3046\u3044\u3046dataclass\u3092\u5b9a\u7fa9\u3057\u3066\u3002 from dataclasses import dataclass, asdict @dataclass class Point: x: int y: int json.dumps\u3059\u308b\u3068TypeError import json p = Point(x=1, y=2) # TypeError: Object of type Point is not JSON serializable print(json.dumps(p\u2026","version":"1.0","height":"190","type":"rich","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fpod.hatenablog.com%2Fentry%2F2018%2F09%2F29%2F222455\" title=\"datacalsses\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u542b\u3093\u3060\u5024\u3092JSON\u306b\u3059\u308b\u3068\u304d\u306e\u30e1\u30e2 - podhmo&#39;s diary\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","blog_url":"https://pod.hatenablog.com/","published":"2018-09-29 22:25:09","url":"https://pod.hatenablog.com/entry/2018/09/29/222455","blog_title":"podhmo's diary"}