<?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>Null conversion in a!tojson</title><link>https://community.appian.com/discussions/f/general/20403/null-conversion-in-a-tojson</link><description>For my service integration, i have to send the request in json format. 
 I am converting my nested CDT into json format by using a!tojson function. 
 Here the issue is my service has some optional input parameters and when i am passing null for those</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Null conversion in a!tojson</title><link>https://community.appian.com/thread/79663?ContentTypeID=1</link><pubDate>Thu, 18 Feb 2021 13:44:06 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:69516e83-f56f-4d77-9409-eaaa8c0e12f2</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;I&amp;#39;m guessing it has to do with the JSON spec used by the system you&amp;#39;re targetting - to be fair, the &amp;quot;null&amp;quot; literal was lowercase in the JSON in any examples I saw (not that I know much about it otherwise), I capitalized it here for effect - which may have been a bad idea ;-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Null conversion in a!tojson</title><link>https://community.appian.com/thread/79656?ContentTypeID=1</link><pubDate>Thu, 18 Feb 2021 07:17:18 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:95378735-d906-4ed5-9dce-1003d6c07a3b</guid><dc:creator>Ram</dc:creator><description>&lt;p&gt;That is working perfectly but what makes the difference between NULL and null ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Null conversion in a!tojson</title><link>https://community.appian.com/thread/79629?ContentTypeID=1</link><pubDate>Wed, 17 Feb 2021 14:57:04 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:259c3634-24b2-4e61-9cde-c469fd70de13</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Well considering the Appian data type for JSON &lt;strong&gt;&lt;em&gt;is&lt;/em&gt;&lt;/strong&gt;&lt;em&gt;&lt;/em&gt; text, i&amp;#39;m not sure what&amp;#39;s happening there.&amp;nbsp; Perhaps try making the literal &amp;quot;null&amp;quot; value you substitute in lower-case?&amp;nbsp; I left mine upper-case for the sake of visibility, but most examples I found were lower (in case it even matters).&lt;br /&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/11/pastedimage1613573905020v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Null conversion in a!tojson</title><link>https://community.appian.com/thread/79612?ContentTypeID=1</link><pubDate>Wed, 17 Feb 2021 09:11:04 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:fd824b2d-380a-4f34-af21-ab2052d5abfd</guid><dc:creator>Ram</dc:creator><description>&lt;p&gt;Hi &lt;a href="/members/mikes0011"&gt;Mike Schmitt&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I tried using the regular expression as you suggested but when i used the regular expression it seems my data type is changing from json to text and due to that my integration object is failing by saying bad request.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Null conversion in a!tojson</title><link>https://community.appian.com/thread/79567?ContentTypeID=1</link><pubDate>Mon, 15 Feb 2021 16:50:07 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:40928229-9eec-4630-9ffe-7ce0890f3851</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;I can confirm this is how it behaves when using a typecast CDT.&amp;nbsp; Have you considered using a Regular Expression to replace empty quotes in the resulting JSON string with NULL literals prior to passing it to your external service?&amp;nbsp; That seems like a bit of a workaround but it might be better than continuing to spin your wheels dealing with Appian&amp;#39;s inconsistent treatment of NULL values.&lt;/p&gt;
&lt;p&gt;i.e. something like this:&lt;br /&gt;&lt;pre class="ui-code" data-mode="java"&gt;regexreplaceall(
  pattern: &amp;quot;(:)&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;,
  searchString: a!toJson(
    &amp;#39;type!{urn:com:appian:types:TEST}TEST_testCdt&amp;#39;(
      id: null(),
      date: null(),
      createdBy: &amp;quot;&amp;quot;,
      modifiedBy: null()
    )
  ),
  replacementString: &amp;quot;$1NULL&amp;quot;
)&lt;/pre&gt;&lt;br /&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/11/pastedimage1613408244758v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Null conversion in a!tojson</title><link>https://community.appian.com/thread/79566?ContentTypeID=1</link><pubDate>Mon, 15 Feb 2021 16:46:14 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c4b85bcd-7fda-4301-9e7a-79c2be3a2b43</guid><dc:creator>Ram</dc:creator><description>&lt;p&gt;Hi &lt;a href="/members/mikes0011"&gt;Mike Schmitt&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thank you for the response.&lt;/p&gt;
&lt;p&gt;I am trying to type-cast the CDT and converting to json.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;a!toJson(&lt;br /&gt;&amp;nbsp; &amp;#39;type!{urn:com:appian:types}_testCDT&amp;#39;(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; name: &amp;quot;ram&amp;quot;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; age: Null,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; place: &amp;quot;&amp;quot;&lt;br /&gt;&amp;nbsp; )&lt;br /&gt;)&lt;/p&gt;
&lt;p&gt;All fields are having the datatype as Text in CDT.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am getting the response like&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span class="CollapsibleOutputNode---print_value"&gt;&amp;quot;{&amp;quot;name&amp;quot;:&amp;quot;ram&amp;quot;,&amp;quot;age&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;place&amp;quot;:&amp;quot;&amp;quot;}&amp;quot;&lt;/span&gt;&lt;span class="CollapsibleOutputNode---print_element_type"&gt;(Text)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Null conversion in a!tojson</title><link>https://community.appian.com/thread/79562?ContentTypeID=1</link><pubDate>Mon, 15 Feb 2021 16:26:18 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3490223e-cdc3-40cd-9dca-3a9a568e70bd</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;After a quick test I can confirm that &lt;em&gt;a!toJson()&lt;/em&gt; sets the value to &amp;quot;null&amp;quot; if it&amp;#39;s passed a literal null, and only to empty text (&amp;quot;&amp;quot;) when empty text is passed.&amp;nbsp; I&amp;#39;m not sure what data you&amp;#39;re feeding it, but you might need to first consider whether the data itself is quite correct.&lt;br /&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/11/pastedimage1613406395931v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>