{"id":1617,"date":"2023-04-17T09:24:46","date_gmt":"2023-04-17T02:24:46","guid":{"rendered":"https:\/\/csharptutorial.net\/?page_id=1617"},"modified":"2024-12-14T23:10:34","modified_gmt":"2024-12-14T16:10:34","slug":"csharp-prototype-pattern","status":"publish","type":"page","link":"https:\/\/www.csharptutorial.net\/csharp-design-patterns\/csharp-prototype-pattern\/","title":{"rendered":"C# Prototype Pattern"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you&#8217;ll learn how to use the C# Prototype pattern to create new objects by cloning existing ones.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction to the C# Prototype Pattern<\/h2>\n\n\n\n<p>In C#, <a target=\"_blank\" href=\"https:\/\/csharptutorial.net\/csharp-tutorial\/csharp-class\/\" rel=\"noreferrer noopener\">classes<\/a> are blueprints for creating new objects. From classes, you use the new operator to create an object.<\/p>\n\n\n\n<p>The Prototype is a creational design pattern that allows you to create new objects by cloning existing objects. In other words, the Prototype pattern allows you to create new objects from existing ones by cloning them without specifying the exact class of the objects.<\/p>\n\n\n\n<p>The Prototype pattern is proper when you create new objects similar to existing ones but with some differences in their state or behavior.<\/p>\n\n\n\n<p>The Prototype pattern is also helpful for creating a complex object that may incur overhead. So, you want to avoid the complexity and the overhead by cloning an existing object instead of creating a new one from scratch.<\/p>\n\n\n\n<p>To implement the Prototype pattern, you follow these steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, define an <a href=\"https:\/\/csharptutorial.net\/csharp-tutorial\/csharp-interface\/\" target=\"_blank\" rel=\"noreferrer noopener\">interface<\/a> or <a href=\"https:\/\/csharptutorial.net\/csharp-tutorial\/csharp-abstract-class\/\" target=\"_blank\" rel=\"noreferrer noopener\">abstract class<\/a> that specifies a method for cloning objects.<\/li>\n\n\n\n<li>Second, create concrete classes implementing the interface or extending the abstract class. Each concrete class represents a specific object type that you can copy later.<\/li>\n<\/ul>\n\n\n\n<p>To create a new object, you call the Clone() method on the prototype object first and then modify the properties of the cloned object.<\/p>\n\n\n\n<p>The following UML diagram illustrates how the Prototype pattern works.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/csharptutorial.net\/wp-content\/uploads\/2023\/04\/CSharp-Prototype-Pattern.svg\" alt=\"C# Prototype Pattern\" class=\"wp-image-1619\"\/><\/figure>\n\n\n\n<p>The Prototype pattern involves the following participants:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Prototype<\/strong>: The Prototype can be an <a href=\"https:\/\/csharptutorial.net\/csharp-tutorial\/csharp-interface\/\">interface<\/a> or an <a href=\"https:\/\/csharptutorial.net\/csharp-tutorial\/csharp-abstract-class\/\">abstract class<\/a>. The Prototype interface (or abstract class) has the <code>Clone()<\/code> method that creates a new object from an existing object.<\/li>\n\n\n\n<li><strong>ConcretePrototype<\/strong>: This is a concrete class of the Prototype interface. The <code>ConcretePrototype<\/code> class implements the <code>Clone()<\/code> method for cloning an object.<\/li>\n\n\n\n<li><strong>Client<\/strong>: This is the client code that uses the Prototype interface for creating new objects. The client creates a new object by cloning an existing object and then customizes the cloned object as needed.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">C# Prototype pattern example<\/h2>\n\n\n\n<p>The following C# program demonstrates how to use the Prototype pattern by creating a Warrior prototype and cloning it to create a new warrior with some differences in its properties:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-keyword\">using<\/span> <span class=\"hljs-keyword\">static<\/span> System.Console;\n\n<span class=\"hljs-keyword\">namespace<\/span> <span class=\"hljs-title\">PrototypePattern<\/span>;\n\n<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">interface<\/span> <span class=\"hljs-title\">IPrototype<\/span>&lt;<span class=\"hljs-title\">T<\/span>&gt;\n{\n    <span class=\"hljs-function\">T <span class=\"hljs-title\">Clone<\/span>(<span class=\"hljs-params\"><\/span>)<\/span>;\n}\n\n<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">Warrior<\/span> : <span class=\"hljs-title\">IPrototype<\/span>&lt;<span class=\"hljs-title\">Warrior<\/span>&gt;\n{\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">string<\/span> Name  {  <span class=\"hljs-keyword\">get<\/span>; <span class=\"hljs-keyword\">set<\/span>;  }\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">int<\/span> Health {  <span class=\"hljs-keyword\">get<\/span>; <span class=\"hljs-keyword\">set<\/span>; }\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">int<\/span> AttackPower {   <span class=\"hljs-keyword\">get<\/span>; <span class=\"hljs-keyword\">set<\/span>;  }\n\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-title\">Warrior<\/span>(<span class=\"hljs-params\"><span class=\"hljs-keyword\">string<\/span> name, <span class=\"hljs-keyword\">int<\/span> health, <span class=\"hljs-keyword\">int<\/span> attackPower<\/span>)<\/span>\n    {\n        Name = name;\n        Health = health;\n        AttackPower = attackPower;\n    }\n\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">override<\/span> <span class=\"hljs-keyword\">string<\/span> <span class=\"hljs-title\">ToString<\/span>(<span class=\"hljs-params\"><\/span>)<\/span> \n        =&gt; <span class=\"hljs-string\">$\"Name: <span class=\"hljs-subst\">{Name}<\/span>, Health:<span class=\"hljs-subst\">{Health}<\/span>, AttackPower: <span class=\"hljs-subst\">{AttackPower}<\/span>\"<\/span>;\n\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">public<\/span> Warrior <span class=\"hljs-title\">Clone<\/span>(<span class=\"hljs-params\"><\/span>)<\/span> =&gt; (Warrior)MemberwiseClone();\n\n}\n\n<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">Client<\/span>\n{\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">static<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">Main<\/span>(<span class=\"hljs-params\"><span class=\"hljs-keyword\">string<\/span>&#91;] args<\/span>)<\/span>\n    {\n        <span class=\"hljs-comment\">\/\/ Create an instance of the Warrior prototype<\/span>\n        <span class=\"hljs-keyword\">var<\/span> loki = <span class=\"hljs-keyword\">new<\/span> Warrior(<span class=\"hljs-string\">\"Loki\"<\/span>, <span class=\"hljs-number\">100<\/span>, <span class=\"hljs-number\">20<\/span>);\n\n        <span class=\"hljs-comment\">\/\/ Clone the Loki warrior to create<\/span>\n        <span class=\"hljs-comment\">\/\/ a new warrior named Thor<\/span>\n        <span class=\"hljs-keyword\">var<\/span> thor = loki.Clone();\n        thor.Name = <span class=\"hljs-string\">\"Thor\"<\/span>;\n        thor.Health = <span class=\"hljs-number\">120<\/span>;\n\n        <span class=\"hljs-comment\">\/\/ Now we have two different warrior objects with<\/span>\n        <span class=\"hljs-comment\">\/\/ similar properties but with some differences<\/span>\n        WriteLine(loki);\n        WriteLine(thor);\n    }\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">Name: Loki, Health:100, AttackPower: 20\nName: Thor, Health:120, AttackPower: 20<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>How it works.<\/p>\n\n\n\n<p>First, define an interface called <code>IPrototype<\/code> with a generic type parameter <code>T<\/code>. The <code>Prototype&lt;T&gt;<\/code> has a method called <code>Clone()<\/code> that will be implemented by the concrete prototype for cloning an object:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">interface<\/span> <span class=\"hljs-title\">IPrototype<\/span>&lt;<span class=\"hljs-title\">T<\/span>&gt;\n{\n    <span class=\"hljs-function\">T <span class=\"hljs-title\">Clone<\/span>(<span class=\"hljs-params\"><\/span>)<\/span>;\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Second, define a concrete class <code>Warrior <\/code>that implements the <code>IPrototype<\/code> interface. The <code>Warrior<\/code> class has three properties <code>Name<\/code>, <code>Health<\/code>, and <code>AttackPower<\/code>. Also, it has a constructor to initialize these properties:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">Warrior<\/span> : <span class=\"hljs-title\">IPrototype<\/span>&lt;<span class=\"hljs-title\">Warrior<\/span>&gt;\n{\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">string<\/span> Name  {  <span class=\"hljs-keyword\">get<\/span>; <span class=\"hljs-keyword\">set<\/span>;  }\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">int<\/span> Health {  <span class=\"hljs-keyword\">get<\/span>; <span class=\"hljs-keyword\">set<\/span>; }\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">int<\/span> AttackPower {   <span class=\"hljs-keyword\">get<\/span>; <span class=\"hljs-keyword\">set<\/span>;  }\n\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-title\">Warrior<\/span>(<span class=\"hljs-params\"><span class=\"hljs-keyword\">string<\/span> name, <span class=\"hljs-keyword\">int<\/span> health, <span class=\"hljs-keyword\">int<\/span> attackPower<\/span>)<\/span>\n    {\n        Name = name;\n        Health = health;\n        AttackPower = attackPower;\n    }\n\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">override<\/span> <span class=\"hljs-keyword\">string<\/span> <span class=\"hljs-title\">ToString<\/span>(<span class=\"hljs-params\"><\/span>)<\/span> \n        =&gt; <span class=\"hljs-string\">$\"Name: <span class=\"hljs-subst\">{Name}<\/span>, Health:<span class=\"hljs-subst\">{Health}<\/span>, AttackPower: <span class=\"hljs-subst\">{AttackPower}<\/span>\"<\/span>;\n\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">public<\/span> Warrior <span class=\"hljs-title\">Clone<\/span>(<span class=\"hljs-params\"><\/span>)<\/span> =&gt; (Warrior)MemberwiseClone();\n\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>Warrior<\/code> class overrides the <code>ToString()<\/code> method to return a string representation of the warrior object.<\/p>\n\n\n\n<p>The <code>Warrior<\/code> class also implements the <code><code>Clone()<\/code><\/code> method. The <code><code>Clone()<\/code><\/code> method uses the <code>MemberwiseClone()<\/code> method that creates a shallow copy of the <code>Warrior<\/code> object.<\/p>\n\n\n\n<p class=\"note\">Note that the&nbsp;<code>MemberwiseClone<\/code>&nbsp;method creates a shallow copy of an object by creating a new object and then copying the nonstatic fields of the object to the new object. If a field is a value type, it performs a bit-by-bit copy of the field. If a field is a reference type, it copies only the reference.<\/p>\n\n\n\n<p>Since the properties of the <code>Warrior<\/code> class are value types (except for the <code>string<\/code>, which is a reference type but a special case), the shallow copy is fine in this case.<\/p>\n\n\n\n<p>Third, define the <code>Client<\/code> class with the <code>Main()<\/code> method as the main entry point of the program:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">Client<\/span>\n{\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">static<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">Main<\/span>(<span class=\"hljs-params\"><span class=\"hljs-keyword\">string<\/span>&#91;] args<\/span>)<\/span>\n    {\n        <span class=\"hljs-comment\">\/\/ Create an instance of the Warrior prototype<\/span>\n        <span class=\"hljs-keyword\">var<\/span> loki = <span class=\"hljs-keyword\">new<\/span> Warrior(<span class=\"hljs-string\">\"Loki\"<\/span>, <span class=\"hljs-number\">100<\/span>, <span class=\"hljs-number\">20<\/span>);\n\n        <span class=\"hljs-comment\">\/\/ Clone the Loki warrior to create<\/span>\n        <span class=\"hljs-comment\">\/\/ a new warrior named Thor<\/span>\n        <span class=\"hljs-keyword\">var<\/span> thor = loki.Clone();\n        thor.Name = <span class=\"hljs-string\">\"Thor\"<\/span>;\n        thor.Health = <span class=\"hljs-number\">120<\/span>;\n\n        <span class=\"hljs-comment\">\/\/ Now we have two different warrior objects with<\/span>\n        <span class=\"hljs-comment\">\/\/ similar properties but with some differences<\/span>\n        WriteLine(loki);\n        WriteLine(thor);\n    }\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In the <code>Main()<\/code> method, we create a new instance of the <code>Warrior<\/code> prototype with the name <code>Loki<\/code>, health <code>100<\/code>, and attack power <code>20<\/code>. Then we clone the <code>Loki<\/code> warrior using the <code>Clone()<\/code> method to create a new warrior named <code>Thor<\/code>.<\/p>\n\n\n\n<p>The <code>Thor<\/code> warrior has the same properties as the <code>Loki<\/code> warrior, except for the <code>Name<\/code> and <code>Health<\/code> properties, which are set to <code>Thor<\/code> and <code>120<\/code>, respectively.<\/p>\n\n\n\n<p>The benefit of using the Prototype pattern is that you can create new warriors with similar properties to an existing one without explicitly specifying the <code>Warrior<\/code> class. Hence, the Prototype pattern offers flexibility and reduces code duplication.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the Prototype pattern to create a new object by cloning an existing one without specifying the objects&#8217; class explicitly.<\/li>\n\n\n\n<li>Use the <code>MemberwiseClone<\/code> method to create a shallow copy of the current object.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful ?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"1617\"\n\t\t\t\tdata-post-url=\"https:\/\/www.csharptutorial.net\/csharp-design-patterns\/csharp-prototype-pattern\/\"\n\t\t\t\tdata-post-title=\"C# Prototype Pattern\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"1617\"\n\t\t\t\tdata-post-url=\"https:\/\/www.csharptutorial.net\/csharp-design-patterns\/csharp-prototype-pattern\/\"\n\t\t\t\tdata-post-title=\"C# Prototype Pattern\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you&#8217;ll learn how to use the C# Prototype pattern to create new objects by cloning existing ones.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1441,"menu_order":8,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1617","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages\/1617","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/comments?post=1617"}],"version-history":[{"count":5,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages\/1617\/revisions"}],"predecessor-version":[{"id":2718,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages\/1617\/revisions\/2718"}],"up":[{"embeddable":true,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages\/1441"}],"wp:attachment":[{"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/media?parent=1617"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}