{"id":3692,"date":"2023-08-21T23:09:53","date_gmt":"2023-08-22T06:09:53","guid":{"rendered":"https:\/\/ioflood.com\/blog\/?p=3692"},"modified":"2024-03-12T14:54:05","modified_gmt":"2024-03-12T21:54:05","slug":"python-dataclass-funadmentals-and-usage-guide-with-examples","status":"publish","type":"post","link":"https:\/\/ioflood.com\/blog\/python-dataclass-funadmentals-and-usage-guide-with-examples\/","title":{"rendered":"Python Dataclass | Funadmentals, Usage, and Examples"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"alignright size-full is-resized\"><img decoding=\"async\" src=\"https:\/\/ioflood.com\/blog\/wp-content\/uploads\/2023\/08\/Artistic-digital-depiction-of-Python-Dataclass-focusing-on-data-handling-simplification-300x300.jpg\" alt=\"Artistic digital depiction of Python Dataclass focusing on data handling simplification\" width=\"300\" height=\"300\" title=\"\"><\/figure>\n<\/div>\n<p>As a type of class specifically designed for storing data, Python dataclasses are a hidden gem in Python&#8217;s toolbox that can make your life as a programmer much easier.<\/p>\n<p>This comprehensive guide aims to equip you with the knowledge and skills to effectively use Python dataclasses in your projects.<\/p>\n<p>By the end of this post, you&#8217;ll gain a solid understanding of Python dataclasses, their purpose, benefits, and how to use them to write cleaner, more efficient code. So, let&#8217;s dive in and uncover the power of Python dataclasses!<\/p>\n<h2>TL;DR: What are Python dataclasses?<\/h2>\n<blockquote><p>\n  Python dataclasses are a type of class used for storing data. They automatically generate special methods like <code>__init__()<\/code> and <code>__repr__()<\/code> that make managing and manipulating data easier. They are part of Python&#8217;s standard library since Python 3.7. For more advanced methods, background, tips and tricks, continue reading the article.\n<\/p><\/blockquote>\n<p>Example:<\/p>\n<pre><code class=\"language-python line-numbers\">from dataclasses import dataclass\n\n@dataclass\nclass Example:\n    field1: int\n    field2: str\n\nexample = Example(1, 'example')\nprint(example)\n# Output:\n# Example(field1=1, field2='example')\n<\/code><\/pre>\n<h2>Understanding Python Dataclasses<\/h2>\n<p>A Python dataclass, in essence, is a class specifically designed for storing data. They are part of the <code>dataclasses<\/code> module in Python 3.7 and above. The main principle behind a dataclass is to minimize the amount of boilerplate code required to create classes. This is achieved with the help of a decorator called <code>@dataclass<\/code>.<\/p>\n<p>The <code>@dataclass<\/code> decorator automatically adds special methods to your classes, such as <code>__init__()<\/code> and <code>__repr__()<\/code>, which are usually manually defined in traditional Python classes. These methods are used to initialize objects and represent them as strings for debugging purposes, respectively.<\/p>\n<blockquote><p>\n  Why would you want to use dataclasses over traditional classes? The primary advantage is that dataclasses reduce the amount of code you have to write, making your code more readable and easier to understand.\n<\/p><\/blockquote>\n<p>Let&#8217;s take a look at a simple example of a Python dataclass:<\/p>\n<pre><code class=\"language-python line-numbers\">from dataclasses import dataclass\n\n@dataclass\nclass Book:\n    title: str\n    author: str\n    pages: int\n    price: float\n\nbook1 = Book(\"Python Basics\", \"John Doe\", 200, 39.99)\nprint(book1)\n# Output:\n# Book(title='Python Basics', author='John Doe', pages=200, price=39.99)\n<\/code><\/pre>\n<p>In this example, <code>Book<\/code> is a Python dataclass with four fields: <code>title<\/code>, <code>author<\/code>, <code>pages<\/code>, and <code>price<\/code>. The <code>@dataclass<\/code> decorator automatically generates an <code>__init__()<\/code> method to initialize these fields and a <code>__repr__()<\/code> method to represent the <code>Book<\/code> object as a string.<\/p>\n<p>Therefore, when we create a <code>Book<\/code> object and print it, Python automatically calls the <code>__repr__()<\/code> method to display the object.<\/p>\n<p>The <code>@dataclass<\/code> decorator is a powerful tool that can make your code cleaner and more efficient. By reducing the amount of boilerplate code you have to write, dataclasses allow you to focus on the logic of your program rather than the implementation details of your classes. This can result in code that is easier to read, write, and maintain, making dataclasses a valuable tool for any Python developer.<\/p>\n<h2>Advanced Usage of Python Dataclasses<\/h2>\n<p>Python dataclasses are not just about reducing boilerplate code. They come with a plethora of advanced features that can make your programming life even easier. In this section, we&#8217;ll delve deeper into these features, such as default values and type hints, and see them in action.<\/p>\n<h3>Default Values<\/h3>\n<p>One of the advanced features of Python dataclasses is the ability to provide default values for the fields. This can be done using the familiar syntax used in function arguments. Here&#8217;s how you can do it:<\/p>\n<pre><code class=\"language-python line-numbers\">from dataclasses import dataclass\n\n@dataclass\nclass Book:\n    title: str = 'Unknown Title'\n    author: str = 'Unknown Author'\n    pages: int = 0\n    price: float = 0.0\n\nbook1 = Book()\nprint(book1)\n# Output:\n# Book(title='Unknown Title', author='Unknown Author', pages=0, price=0.0)\n<\/code><\/pre>\n<p>In this example, if we create a <code>Book<\/code> object without providing any arguments, Python will use the default values specified in the dataclass.<\/p>\n<p>Example of creating a <code>Book<\/code> object with some arguments:<\/p>\n<pre><code class=\"language-python line-numbers\">book2 = Book('Python Advanced', 'Jane Doe')\nprint(book2)\n# Output:\n# Book(title='Python Advanced', author='Jane Doe', pages=0, price=0.0)\n<\/code><\/pre>\n<p>In this example, Python uses the provided arguments for <code>title<\/code> and <code>author<\/code>, and the default values for <code>pages<\/code> and <code>price<\/code>.<\/p>\n<h3>Type Hints<\/h3>\n<p>Python dataclasses also support type hints. Type hints are a way of indicating the expected type of a variable or a function return. This can make your code more readable and self-documenting.<\/p>\n<p>In the previous examples, we have already seen type hints in action. They are the <code>str<\/code>, <code>int<\/code>, and <code>float<\/code> keywords that follow the colon after the field names.<\/p>\n<h2>Comparing Dataclasses with Other Python Structures<\/h2>\n<p>Understanding how Python dataclasses compare with other Python structures is key to knowing when to use them. Let&#8217;s take a closer look at how they stack up against traditional classes, tuples, and dictionaries.<\/p>\n<h3>Dataclasses vs Traditional Classes<\/h3>\n<p>In traditional classes, you have to manually define special methods like <code>__init__()<\/code> and <code>__repr__()<\/code>. With dataclasses, these methods are automatically generated, saving you the trouble of writing them yourself.<\/p>\n<p>This makes your code cleaner and more efficient. However, traditional classes offer more flexibility as you can customize these methods to suit your needs.<\/p>\n<p>Here is an example code block comparing a traditional class with a data class:<\/p>\n<h4>Traditional class:<\/h4>\n<pre><code class=\"language-python line-numbers\">class TraditionalBook:\n    def __init__(self, title, author, pages, price):\n        self.title = title\n        self.author = author\n        self.pages = pages\n        self.price = price\n\n    # Define the __repr__ method here\n    def __repr__(self):\n        return f\"TraditionalBook(title={self.title}, author={self.author}, pages={self.pages}, price={self.price})\"\n\ntraditional_book = TraditionalBook(\"Python Basics\", \"John Doe\", 200, 39.99)\nprint(traditional_book)\n# Output: TraditionalBook(title=Python Basics, author=John Doe, pages=200, price=39.99)\n<\/code><\/pre>\n<h4>Dataclass:<\/h4>\n<pre><code class=\"language-python line-numbers\">from dataclasses import dataclass\n\n@dataclass\nclass DataClassBook:\n    title: str\n    author: str\n    pages: int\n    price: float\n\ndata_class_book = DataClassBook(\"Python Basics\", \"John Doe\", 200, 39.99)\nprint(data_class_book)\n# Output: DataClassBook(title=Python Basics, author=John Doe, pages=200, price=39.99)\n<\/code><\/pre>\n<p>As you can see, the data class version is much shorter and easier to read. The <code>__init__()<\/code> and <code>__repr__()<\/code> methods are automatically implemented for you.<\/p>\n<h3>Dataclasses vs Tuples<\/h3>\n<p>Both dataclasses and tuples are used to group related data. However, tuples are immutable and their elements are accessed using indices, which can be less readable when dealing with complex data.<\/p>\n<p>On the other hand, dataclasses are mutable and their fields can be accessed by name, making your code more self-explanatory.<\/p>\n<p>Here are some examples showcasing tuples vs dataclasses:<\/p>\n<h4>Tuples:<\/h4>\n<pre><code class=\"language-python line-numbers\"># Define a book as a tuple\nbook_tuple = (\"Python Basics\", \"John Doe\", 200, 39.99)\nprint(book_tuple)\n# Output: ('Python Basics', 'John Doe', 200, 39.99)\n\n# Access elements by index\nprint(book_tuple[0])  # Output: 'Python Basics'\nprint(book_tuple[1])  # Output: 'John Doe'\n<\/code><\/pre>\n<p>Here, unless you know by heart what each index means, it&#8217;s hard to understand what the data represents just by reading the code.<\/p>\n<h4>Dataclasses:<\/h4>\n<pre><code class=\"language-python line-numbers\">from dataclasses import dataclass\n\n@dataclass\nclass Book:\n    title: str\n    author: str\n    pages: int\n    price: float\n\n# Define a book as a Data Class\nbook_dataclass = Book(\"Python Basics\", \"John Doe\", 200, 39.99)\nprint(book_dataclass)\n# Output: Book(title='Python Basics', author='John Doe', pages=200, price=39.99)\n\n# Access elements by name\nprint(book_dataclass.title)  # Output: 'Python Basics'\nprint(book_dataclass.author)  # Output: 'John Doe'\n<\/code><\/pre>\n<p>With dataclasses, the code has immediately become more readable because we can access the fields by their names and we know exactly what each field represents.<\/p>\n<h3>Dataclasses vs Dictionaries<\/h3>\n<p>Dictionaries, like dataclasses, allow access to their elements by name. But dictionaries are more flexible as they can hold any number of items and of any type. Dataclasses, however, have a fixed number of fields and each field has a specific type. This makes dataclasses more suitable when you have a fixed schema to follow.<\/p>\n<p>Here are some examples showing the difference between dictionaries and dataclasses in Python:<\/p>\n<h4>Dictionaries:<\/h4>\n<pre><code class=\"language-python line-numbers\"># Define a book as a dictionary\nbook_dict = {\"title\": \"Python Basics\", \"author\": \"John Doe\", \"pages\": 200, \"price\": 39.99}\nprint(book_dict)\n# Output: {'title': 'Python Basics', 'author': 'John Doe', 'pages': 200, 'price': 39.99}\n\n# Add a new field\nbook_dict[\"ISBN\"] = \"123-456-789\"\nprint(book_dict)\n# Output: {'title': 'Python Basics', 'author': 'John Doe', 'pages': 200, 'price': 39.99, 'ISBN': '123-456-789'}\n\n# Access elements by key\nprint(book_dict[\"title\"])  # Output: 'Python Basics'\nprint(book_dict[\"author\"])  # Output: 'John Doe'\n<\/code><\/pre>\n<p>Here, dictionaries can be easily modified (add or remove items) and do not require a fixed schema.<\/p>\n<h4>Dataclasses:<\/h4>\n<pre><code class=\"language-python line-numbers\">from dataclasses import dataclass\n\n@dataclass\nclass Book:\n    title: str\n    author: str\n    pages: int\n    price: float\n\n# Define a book as a Data Class\nbook_dataclass = Book(\"Python Basics\", \"John Doe\", 200, 39.99)\nprint(book_dataclass)\n# Output: Book(title='Python Basics', author='John Doe', pages=200, price=39.99)\n\n# Trying to add a new field will raise an AttributeError\nbook_dataclass.ISBN = \"123-456-789\"  # Raises AttributeError: 'Book' object has no attribute 'ISBN'\n\n# Access elements by name\nprint(book_dataclass.title)  # Output: 'Python Basics'\nprint(book_dataclass.author)  # Output: 'John Doe'\n<\/code><\/pre>\n<p>In this case, the structure is fixed by the dataclass definition. It is not as flexible as a dictionary, but it provides a clear definition of the data structure we are using, which can be beneficial in many cases.<\/p>\n<h3>Summary of Dataclasses vs Other Structures<\/h3>\n<p>From the above examples, you can see that Dataclasses serve an important role in Python programming. However, there are certainly situations where other data structures are more appropriate.<\/p>\n<p>Here is a table summarizing the key differences:<\/p>\n<table>\n<thead>\n<tr>\n<th><\/th>\n<th>Dataclasses<\/th>\n<th>Traditional Classes<\/th>\n<th>Tuples<\/th>\n<th>Dictionaries<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Automatically generates special methods<\/td>\n<td>Yes<\/td>\n<td>No<\/td>\n<td>N\/A<\/td>\n<td>N\/A<\/td>\n<\/tr>\n<tr>\n<td>Mutable<\/td>\n<td>Yes<\/td>\n<td>Yes<\/td>\n<td>No<\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td>Elements accessed by name<\/td>\n<td>Yes<\/td>\n<td>Yes<\/td>\n<td>No<\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td>Can hold any number of items of any type<\/td>\n<td>No<\/td>\n<td>Yes<\/td>\n<td>Yes<\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td>Suitable when you have a fixed schema<\/td>\n<td>Yes<\/td>\n<td>Yes<\/td>\n<td>No<\/td>\n<td>No<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<blockquote><p>\n  If you need immutability and order, tuples are the way to go. If you need a flexible container that can hold any number of items of any type, dictionaries are your best bet. But if you&#8217;re dealing with complex data and want to make your code cleaner and more efficient, dataclasses are a perfect choice.\n<\/p><\/blockquote>\n<h3>Immutability and Dataclasses<\/h3>\n<p>Immutability is a property of an object whose state cannot be modified after it is created. In Python, tuples are an example of an <a href=\"https:\/\/ioflood.com\/blog\/mutable-vs-immutable-in-python-object-data-types-explained\/\">immutable data structure<\/a>. Dataclasses, by default, are mutable.<\/p>\n<blockquote><p>\n  You can make Dataclasses immutable by setting the <code>frozen<\/code> parameter of the <code>@dataclass<\/code> decorator to <code>True<\/code>. This can be useful when you want to ensure that an object remains constant throughout its lifetime.\n<\/p><\/blockquote>\n<p>Example of making a dataclass immutable:<\/p>\n<pre><code class=\"language-python line-numbers\">from dataclasses import dataclass\n\n@dataclass(frozen=True)\nclass ImmutableBook:\n    title: str\n    author: str\n    pages: int\n    price: float\n\ntry:\n    book = ImmutableBook('Python Basics', 'John Doe', 200, 39.99)\n    book.title = 'Python Advanced'  # This will raise an error\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n<\/code><\/pre>\n<blockquote><p>\n  In this example, trying to modify the <code>title<\/code> of the <code>ImmutableBook<\/code> object will raise an <code>AttributeError<\/code> because the dataclass is immutable.\n<\/p><\/blockquote>\n<h2>Python and Object-Oriented Programming<\/h2>\n<p>Python is an object-oriented programming (OOP) language, which means it uses objects and classes as its fundamental building blocks. In Python, everything is an object, and we can create our own objects using classes. OOP in Python provides a clear, intuitive way to structure code, making it more readable and maintainable.<\/p>\n<p>Python&#8217;s approach to OOP is flexible and powerful. It supports multiple inheritance, where a class can inherit from multiple parent classes, and polymorphism, where a subclass can modify the behavior of a parent class. It also supports encapsulation, where data and methods can be bundled together into a single unit, or object.<\/p>\n<p>Python dataclasses fit neatly into Python&#8217;s approach to OOP. A dataclass is essentially a class that&#8217;s been optimized for storing data. It automatically generates special methods that are commonly used in classes, such as <code>__init__()<\/code> and <code>__repr__()<\/code>. This saves you the trouble of writing these methods yourself and makes your classes more efficient and easier to work with.<\/p>\n<p>By using dataclasses, you can take full advantage of Python&#8217;s OOP capabilities while keeping your code clean and efficient. Dataclasses are a perfect example of how Python&#8217;s flexible and powerful OOP features can be leveraged to make your life as a programmer easier.<\/p>\n<h3>Further Reading<\/h3>\n<p>For those who want to delve deeper into Python programming and its object-oriented features, there are many resources available online.<\/p>\n<p>For example you can, <a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/ioflood.com\/blog\/python-data-types\/\">Click Here<\/a> for insights on the world of sequences in Python and learn how to manipulate them efficiently.<\/p>\n<p>Additionaly, here are a few articles that provide a more in-depth look at Python and OOP in general:<\/p>\n<ul>\n<li><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/ioflood.com\/blog\/using-deque-in-python-python-queues-and-stacks-made-easy\/\">Exploring deque in Python<\/a> &#8211; Master Python deque operations for building complex data processing pipelines.<\/p>\n<\/li>\n<li>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/ioflood.com\/blog\/python-array-usage-guide-with-examples\/\">Understanding Python&#8217;s Array Module<\/a> &#8211; Explore Python array examples and use cases for various programming tasks.<\/p>\n<\/li>\n<li>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/realpython.com\/python3-object-oriented-programming\/\" target=\"_blank\" rel=\"noopener\">Guide on Object-Oriented Programming<\/a> &#8211; Comprehensive guide on Python&#8217;s object-oriented programming.<\/p>\n<\/li>\n<li>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/docs.python.org\/3\/reference\/datamodel.html\" target=\"_blank\" rel=\"noopener\">Python&#8217;s Official Data Model Documentation<\/a> &#8211; Detailed insight into Python&#8217;s data model from the official docs.<\/p>\n<\/li>\n<li>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/thepythonguru.com\/python-object-and-classes\/\" target=\"_blank\" rel=\"noopener\">Python Classes and OOP<\/a> &#8211; Understand Python&#8217;s classes and object-oriented programming with Python Guru.<\/p>\n<\/li>\n<\/ul>\n<p>If you&#8217;re interested in learning more about Python dataclasses, there are many resources available online. Here are a few recommended ones:<\/p>\n<ul>\n<li><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/docs.python.org\/3\/library\/dataclasses.html\" target=\"_blank\" rel=\"noopener\">Official Python Documentation on Dataclasses<\/a> &#8211; Explore Python&#8217;s dataclasses from the official Python documentation.<\/p>\n<\/li>\n<li>\n<p>Real Python&#8217;s <a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/realpython.com\/python-data-classes\/\" target=\"_blank\" rel=\"noopener\">Guide on Python 3.7&#8217;s Dataclasses<\/a> dives into Dataclasses in Python 3.7.<\/p>\n<\/li>\n<li>\n<p>Corey Schafer&#8217;s <a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/www.youtube.com\/watch?v=vBH6GRJ1REM\" target=\"_blank\" rel=\"noopener\">Video Tutorial on Python Dataclasses<\/a> helps you understand Python dataclasses.<\/p>\n<\/li>\n<\/ul>\n<h2>Other Python Libraries, Functions, and Tools<\/h2>\n<p>While Python dataclasses are a powerful tool in their own right, there are other Python libraries and tools that can complement them and enhance your Python programming experience. Let&#8217;s take a look at a few of them:<\/p>\n<h3>attrs<\/h3>\n<p><code>attrs<\/code> is a Python library that, like dataclasses, simplifies writing classes. It offers more features than dataclasses and works with older versions of Python. However, it&#8217;s a third-party library and not part of Python&#8217;s standard library, unlike dataclasses. You can learn more about <code>attrs<\/code> <a class=\"wp-editor-md-post-content-link\" href=\"http:\/\/www.attrs.org\/\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n<h3>typing<\/h3>\n<p>The <code>typing<\/code> module in Python is used for type hints, a feature that we&#8217;ve seen in use with dataclasses. Type hints can make your code more readable and help you catch certain types of errors earlier. You can learn more about Python&#8217;s <code>typing<\/code> module <a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/docs.python.org\/3\/library\/typing.html\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n<h3>pydantic<\/h3>\n<p><code>pydantic<\/code> is a data validation library that uses Python type annotations. It&#8217;s useful for parsing complex data, converting from one format to another, and for validation. It can work together with dataclasses to provide data validation. You can learn more about <code>pydantic<\/code> <a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/pydantic-docs.helpmanual.io\/\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n<h2>Wrapping Up:<\/h2>\n<p>Python dataclasses are a powerful tool that can significantly streamline your code, making it more efficient and easier to read. They serve as a type of class specifically designed for storing data, equipped with special methods like <code>__init__()<\/code> and <code>__repr__()<\/code> that are automatically generated. This frees you from the need to write these methods yourself, saving you time and reducing the chance of errors.<\/p>\n<p>When compared with traditional classes, tuples, and dictionaries, Python dataclasses stand out for their efficiency and readability. They offer the flexibility of traditional classes, the order of tuples, and the named access of dictionaries, all while reducing boilerplate code. However, the choice of data structure always depends on the specific needs of your project.<\/p>\n<p>In the broader context of Python programming, dataclasses fit neatly into Python&#8217;s approach to object-oriented programming. They leverage Python&#8217;s OOP capabilities to make your code cleaner and more efficient, demonstrating how Python&#8217;s flexible and powerful OOP features can simplify your life as a programmer.<\/p>\n<p>Mastering Python dataclasses can be a valuable addition to your Python programming skillset. So, start using them in your projects and experience the difference they make. Remember, practice is key when mastering any programming concept. Happy coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As a type of class specifically designed for storing data, Python dataclasses are a hidden gem in Python&#8217;s toolbox that can make your life as a programmer much easier. This comprehensive guide aims to equip you with the knowledge and skills to effectively use Python dataclasses in your projects. By the end of this post, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":18397,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[121,123],"tags":[],"class_list":["post-3692","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming-coding","category-python","cat-121-id","cat-123-id","has_thumb"],"_links":{"self":[{"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/posts\/3692","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/comments?post=3692"}],"version-history":[{"count":10,"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/posts\/3692\/revisions"}],"predecessor-version":[{"id":18398,"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/posts\/3692\/revisions\/18398"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/media\/18397"}],"wp:attachment":[{"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/media?parent=3692"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/categories?post=3692"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ioflood.com\/blog\/wp-json\/wp\/v2\/tags?post=3692"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}