<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Attribute Rule: Unexpected Null error when parsing dictionary in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-unexpected-null-error-when-parsing/m-p/1692486#M102494</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have trouble validating an attribute rule using a dictionary as source (using ArcGIS Pro 3.2.1).&lt;/P&gt;&lt;P&gt;My input is a JSON string (generated by another rule with priority 1):&lt;/P&gt;&lt;LI-CODE lang="java"&gt;{"Dataset1":[], "Dataset2": ["text", "more text"]}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using this expression to parse the JSON:&lt;/P&gt;&lt;LI-CODE lang="markdown"&gt;var out = null;
var dataset = "Dataset2";
var dict = FromJSON(Text($feature.json));

var arr = dict[dataset];

if (IIf(DefaultValue(arr, 0) == 0, false, true)) {
  out = Concatenate(arr, ", ");
}
return out&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the expression in a popup works, as attribute rule the validation always fails at line 5:&lt;/P&gt;&lt;P&gt;Arcade Error, unexpected null&lt;/P&gt;&lt;P&gt;It seems like the dictionary isn't parsed properly as long as I try to use it in an attribute rule.&lt;/P&gt;&lt;P&gt;Returning the dictionary as out works, the validation then complains about dict not being a string.&lt;/P&gt;&lt;P&gt;Returning out = Text(dict) returns the initial JSON string.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I doing wrong here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Mar 2026 12:42:43 GMT</pubDate>
    <dc:creator>Radnod</dc:creator>
    <dc:date>2026-03-25T12:42:43Z</dc:date>
    <item>
      <title>Attribute Rule: Unexpected Null error when parsing dictionary</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-unexpected-null-error-when-parsing/m-p/1692486#M102494</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have trouble validating an attribute rule using a dictionary as source (using ArcGIS Pro 3.2.1).&lt;/P&gt;&lt;P&gt;My input is a JSON string (generated by another rule with priority 1):&lt;/P&gt;&lt;LI-CODE lang="java"&gt;{"Dataset1":[], "Dataset2": ["text", "more text"]}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using this expression to parse the JSON:&lt;/P&gt;&lt;LI-CODE lang="markdown"&gt;var out = null;
var dataset = "Dataset2";
var dict = FromJSON(Text($feature.json));

var arr = dict[dataset];

if (IIf(DefaultValue(arr, 0) == 0, false, true)) {
  out = Concatenate(arr, ", ");
}
return out&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the expression in a popup works, as attribute rule the validation always fails at line 5:&lt;/P&gt;&lt;P&gt;Arcade Error, unexpected null&lt;/P&gt;&lt;P&gt;It seems like the dictionary isn't parsed properly as long as I try to use it in an attribute rule.&lt;/P&gt;&lt;P&gt;Returning the dictionary as out works, the validation then complains about dict not being a string.&lt;/P&gt;&lt;P&gt;Returning out = Text(dict) returns the initial JSON string.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I doing wrong here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2026 12:42:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-unexpected-null-error-when-parsing/m-p/1692486#M102494</guid>
      <dc:creator>Radnod</dc:creator>
      <dc:date>2026-03-25T12:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute Rule: Unexpected Null error when parsing dictionary</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-unexpected-null-error-when-parsing/m-p/1694458#M102665</link>
      <description>&lt;P&gt;In reviewing this item, I found that this expression might work better:&lt;/P&gt;&lt;P&gt;var out = null;&lt;BR /&gt;var dataset = "Dataset2";&lt;/P&gt;&lt;P&gt;// Parse JSON safely&lt;BR /&gt;var dict = FromJSON(Text($feature.json));&lt;/P&gt;&lt;P&gt;if (IsEmpty(dict)) {&lt;BR /&gt;return null;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Check if key exists&lt;BR /&gt;if (!HasKey(dict, dataset)) {&lt;BR /&gt;return null;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;var arr = dict[dataset];&lt;/P&gt;&lt;P&gt;// Ensure it's a valid array with values&lt;BR /&gt;if (!IsEmpty(arr) &amp;amp;&amp;amp; Count(arr) &amp;gt; 0) {&lt;BR /&gt;out = Concatenate(arr, ", ");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;return out;&lt;BR /&gt;&lt;BR /&gt;Why this works better is the HasKey() prevents invalid dictionary access, the IsEmpty avoids null dereferencing, the Count() ensures you're not concatenating an empty array and it removes the DefaultValue(arr, 0) logic which is not reliable for arrays.&amp;nbsp; I don't have the data to test but think it will work.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Apr 2026 20:55:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-unexpected-null-error-when-parsing/m-p/1694458#M102665</guid>
      <dc:creator>Robert_LeClair</dc:creator>
      <dc:date>2026-04-03T20:55:27Z</dc:date>
    </item>
  </channel>
</rss>

