<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: thitkhotau</title>
    <description>The latest articles on DEV Community by thitkhotau (@manhdt).</description>
    <link>https://dev.to/manhdt</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1189553%2F38fc66f5-8fa5-4de0-a7bb-7b2f00b2775c.png</url>
      <title>DEV Community: thitkhotau</title>
      <link>https://dev.to/manhdt</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/manhdt"/>
    <language>en</language>
    <item>
      <title>[Convert] Json &amp; Object</title>
      <dc:creator>thitkhotau</dc:creator>
      <pubDate>Sat, 06 Apr 2024 03:26:39 +0000</pubDate>
      <link>https://dev.to/manhdt/convert-json-object-c7d</link>
      <guid>https://dev.to/manhdt/convert-json-object-c7d</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from dataclasses import dataclass
from typing import TypedDict


class StudentDict(TypedDict):
  Name: str
  Old: int


@dataclass
class Student:
  name: str
  old: int

  def encode(self) -&amp;gt; StudentDict:
    return StudentDict(Name=self.name, Old=self.old)

  @classmethod
  def decode(cls, student: StudentDict) -&amp;gt; "Student":
    return cls(name=student["Name"], old=student["Old"])


def main():
  student = Student(name="John", old=20)
  print(student.encode())
  print(Student.decode(student.encode()))


if __name__ == "__main__":
  main()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>python</category>
    </item>
  </channel>
</rss>
