<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to convert json response to CDT</title><link>https://community.appian.com/discussions/f/integrations/18935/how-to-convert-json-response-to-cdt</link><description>Hello, I have API that returns this data: 
 {&amp;quot;coord&amp;quot;:{&amp;quot;lon&amp;quot;:-3.7,&amp;quot;lat&amp;quot;:40.42},&amp;quot;weather&amp;quot;:[{&amp;quot;id&amp;quot;:801,&amp;quot;main&amp;quot;:&amp;quot;Clouds&amp;quot;,&amp;quot;description&amp;quot;:&amp;quot;few clouds&amp;quot;,&amp;quot;icon&amp;quot;:&amp;quot;02d&amp;quot;}],&amp;quot;base&amp;quot;:&amp;quot;stations&amp;quot;,&amp;quot;main&amp;quot;:{&amp;quot;temp&amp;quot;:297.85,&amp;quot;feels_like&amp;quot;:296.53,&amp;quot;temp_min&amp;quot;:296.15,&amp;quot;temp_max&amp;quot;:299.15</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to convert json response to CDT</title><link>https://community.appian.com/thread/74418?ContentTypeID=1</link><pubDate>Wed, 27 May 2020 20:58:20 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:66882d83-e480-4dd5-9bda-ab04b4c59113</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;If the names are exactly the same in your CDT as the JSON, you can also cast them rather than having to re-write each parameter name. The only downside is you might have to create several nested CDTs to match the data structure. Once you do that though, you could just do this to cast to the correct type:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!result: rule!YourIntegrationRule(),
  cast(
    type!YourTypeName,
    a!fromJson(local!result)
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert json response to CDT</title><link>https://community.appian.com/thread/74400?ContentTypeID=1</link><pubDate>Wed, 27 May 2020 14:00:50 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d6abce62-8b80-4585-b19e-1f02ec49a362</guid><dc:creator>davel001150</dc:creator><description>&lt;p&gt;Once you get the dictionary going, you can use a helper rule you write to accept the dictionary, and use type() function to output your CDT.&lt;/p&gt;
&lt;p&gt;You would literally just write:&lt;/p&gt;
&lt;p&gt;type!yourCDTName(&lt;/p&gt;
&lt;p&gt;lon: ri!input.lon,&lt;/p&gt;
&lt;p&gt;lat: ri!input.lat,&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;Every field has to be typed twice per line for every field, assuming your CDT and the JSON have exactly the same names for every field.&amp;nbsp; It will be tedious, so very good if your CDT structure is very solid and clearly not changing in the future.&amp;nbsp; I&amp;#39;d hate for you to have to go through that tedium twice.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert json response to CDT</title><link>https://community.appian.com/thread/74396?ContentTypeID=1</link><pubDate>Wed, 27 May 2020 11:46:34 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ef13f05e-f8a1-421f-9ca1-55ccf759505a</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;Hi Varsha - I think you may have pasted the wrong text here, or pasted the right text but in the wrong place...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert json response to CDT</title><link>https://community.appian.com/thread/74395?ContentTypeID=1</link><pubDate>Wed, 27 May 2020 11:35:27 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b774a59c-e179-4693-96d8-064e8ae07a68</guid><dc:creator>varsha sri</dc:creator><description>[deleted]&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert json response to CDT</title><link>https://community.appian.com/thread/74394?ContentTypeID=1</link><pubDate>Wed, 27 May 2020 11:32:49 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9ea31089-e0ad-43cd-b4eb-b991824770f0</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;If you take the JSON you&amp;#39;ve provided and use the fn!fromJson() this will convert it to an Appian Dictionary (essentially a set of name/value pairs):&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/18/pastedimage1590579170371v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;What specific need do you have in order to place this into a CDT?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>