<?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>Converting JSON value to dictionary</title><link>https://community.appian.com/discussions/f/data/39574/converting-json-value-to-dictionary</link><description>Hello, I am attempting to convert this into Appian values, but I am having trouble. 
 What would be the best way to convert this? 
 
 Here is the raw response from an API: 
 {&amp;quot;response&amp;quot;:&amp;quot;{\&amp;quot;requestId\&amp;quot;:\&amp;quot;123456\&amp;quot;,\&amp;quot;status\&amp;quot;:0,\&amp;quot;description\&amp;quot;:\&amp;quot;Success</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Converting JSON value to dictionary</title><link>https://community.appian.com/thread/150714?ContentTypeID=1</link><pubDate>Tue, 05 Aug 2025 22:58:42 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:bf593ccf-39ab-4550-a4c5-6f69bedc4d40</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;great, thanks for confirming - hope you&amp;#39;ll go ahead and mash that &amp;quot;verify answer&amp;quot; button too when you get a chance &lt;span class="emoticon" data-url="https://community.appian.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Converting JSON value to dictionary</title><link>https://community.appian.com/thread/150713?ContentTypeID=1</link><pubDate>Tue, 05 Aug 2025 22:43:36 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9279cbc9-8ab0-44ab-9a24-90a4f3d8525c</guid><dc:creator>cindyl5142</dc:creator><description>&lt;p&gt;Actually Mike, I got it!! :) Thank you!!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Converting JSON value to dictionary</title><link>https://community.appian.com/thread/150712?ContentTypeID=1</link><pubDate>Tue, 05 Aug 2025 22:32:05 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:68e87cd8-7856-42cd-847c-a8a12534d767</guid><dc:creator>cindyl5142</dc:creator><description>&lt;p&gt;Great point. Followed those steps of troubleshooting, and it returns this result when getting the body of local!callService.result.body&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:329px;max-width:545px;" height="329" src="/resized-image/__size/1090x658/__key/communityserver-discussions-components-files/16/pastedimage1754432886519v1.png" width="545" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But when trying to convert it to JSON, it states it is not valid.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;PS I really appreciate all your guidance and help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Converting JSON value to dictionary</title><link>https://community.appian.com/thread/150711?ContentTypeID=1</link><pubDate>Tue, 05 Aug 2025 22:19:42 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2272207a-e4b5-4ab3-a4ed-a0ff1c22093d</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;&amp;quot;body&amp;quot; is not under &amp;quot;local!callService&amp;quot; but under &amp;quot;.result&amp;quot;.&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/16/pastedimage1754432215124v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;Therefore the proper syntax would be &lt;strong&gt;&lt;span style="text-decoration:underline;"&gt;&lt;em&gt;a!fromJson(local!callService.result.body)&lt;/em&gt;&lt;/span&gt;&lt;/strong&gt; by what I can see here.&lt;br /&gt;(Or &lt;strong&gt;&lt;em&gt;local!callService.result.body.CensoredResponse&lt;/em&gt;&lt;/strong&gt; even - due to your redactions I&amp;#39;m slightly unclear what the data structure is on that last layer down.)&lt;/p&gt;
&lt;p&gt;The usual way to troubleshoot this would be to start with your response (local!callService) and return just that in your rule, then add &amp;quot;.result&amp;quot; to that and make sure it still works, then add &amp;quot;.body&amp;quot; to that and make sure it still works (and looks like valid JSON), then wrap that in a!fromJson() - when you try to bang it all out at once, you&amp;#39;re setting yourself up for failure because the issue could be anywhere in those several successive logical steps and it&amp;#39;s hard to tell which.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Converting JSON value to dictionary</title><link>https://community.appian.com/thread/150710?ContentTypeID=1</link><pubDate>Tue, 05 Aug 2025 21:45:30 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6def2c18-038b-4b57-a699-69b5cc6281f5</guid><dc:creator>cindyl5142</dc:creator><description>&lt;p&gt;I also tried:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!callService: rule!HCP_POST_trustScore(
    customerPhoneNumber: ri!phoneNumber,
    consentStatus: ri!consentStatus
  ),
  local!jsonArray: a!fromJson(index(local!callService, &amp;quot;body&amp;quot;)),
  a!fromJson(local!jsonArray.response)
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;but the error message Im getting is&amp;nbsp;&lt;/p&gt;
&lt;div id="53f5335509e9f98b2e7a5ae3d546fe9c-split-pane-layout-inner_firstPane" class="SplitPaneLayout---pane SplitPaneLayout---secondary_pane"&gt;
&lt;div class="SplitPaneLayout---contents"&gt;
&lt;div class="TabButtonGroup---tab_group TabButtonGroup---inHeaderBodyLayout TabButtonGroup---margin_above_none"&gt;
&lt;div class="TabButtonGroup---tab_contents_container TabButtonGroup---flush"&gt;
&lt;div class="ContentLayout---content_layout ContentLayout---padding_less ContentLayout---margin_above_none"&gt;
&lt;div class="SectionLayout2---sectionLayout SectionLayout2---margin_above_none"&gt;
&lt;div class="CollapsibleElement---collapsible"&gt;
&lt;div id="a008e71677875da5490c24df7d23b0de_sectionContents" class="SectionLayout2---section_contents SectionLayout2---margin_below_standard" data-testid="SectionLayout2-contentContainer"&gt;
&lt;div class="MessageLayout---message MessageLayout---error"&gt;
&lt;p class="ParagraphText---richtext_paragraph ParagraphText---default_direction ParagraphText---align_start ParagraphText---inMessageLayout ParagraphText---error elements---global_p" data-testid="ParagraphText-paragraph"&gt;Expression evaluation error at function a!fromJson [line 6]: The jsonText parameter must not be null or empty.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Converting JSON value to dictionary</title><link>https://community.appian.com/thread/150709?ContentTypeID=1</link><pubDate>Tue, 05 Aug 2025 21:40:32 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:19396d27-d26c-42ca-bf9c-f345308c4c07</guid><dc:creator>cindyl5142</dc:creator><description>&lt;p&gt;When indexing into body or even trying to do reponse.body, it states it is null. But here is the result of callService&lt;img style="max-height:239px;max-width:558px;" height="239" src="/resized-image/__size/1116x478/__key/communityserver-discussions-components-files/16/pastedimage1754429970061v1.png" width="558" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Converting JSON value to dictionary</title><link>https://community.appian.com/thread/150706?ContentTypeID=1</link><pubDate>Tue, 05 Aug 2025 21:34:44 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ba34d74a-7798-4fa7-94db-e17c6eda7226</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;You&amp;#39;re passing in the entire &amp;quot;callService&amp;quot; response to a!fromJson.&amp;nbsp; Only local!callService.body (or maybe local!callService.response.body) is actually JSON.&lt;/p&gt;
&lt;p&gt;(I can&amp;#39;t quite tell based just on your screenshot - if you can&amp;#39;t figure it out exaclty, post a screenshot of just the value of local!callService, without calling a!fromJson on it.)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Converting JSON value to dictionary</title><link>https://community.appian.com/thread/150705?ContentTypeID=1</link><pubDate>Tue, 05 Aug 2025 21:29:46 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8879e4e8-74da-42db-a947-67f738ef0d56</guid><dc:creator>cindyl5142</dc:creator><description>&lt;p&gt;Hmm :(&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:329px;max-width:775px;" height="329" src="/resized-image/__size/1550x658/__key/communityserver-discussions-components-files/16/pastedimage1754429355725v1.png" width="775" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Converting JSON value to dictionary</title><link>https://community.appian.com/thread/150704?ContentTypeID=1</link><pubDate>Tue, 05 Aug 2025 21:20:02 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a2800c7f-77e5-48b0-a8b8-81595c0c2bcd</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;This seems to work fine:&lt;br /&gt;&lt;img style="max-height:184px;max-width:368px;" height="184" src="/resized-image/__size/736x368/__key/communityserver-discussions-components-files/16/pastedimage1754428760369v3.png" width="368" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Converting JSON value to dictionary</title><link>https://community.appian.com/thread/150703?ContentTypeID=1</link><pubDate>Tue, 05 Aug 2025 21:16:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1be905b9-aeb6-42af-86ac-642a53763c7f</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;The raw response there doesn&amp;#39;t look like standard JSON per se - at the very least it looks as if it&amp;#39;s been &amp;quot;nested&amp;quot; in a way that causes most of the double quotes to be &amp;quot;backslash escaped&amp;quot;.&amp;nbsp; I&amp;#39;m guessing you need to call a!fromJson() on the initial response and then call a!fromJson() again on the &amp;quot;.response&amp;quot; property of the first call.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/16/pastedimage1754428566937v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>