<?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 Re: JSON.parse - Passing variable into query.outfields. in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/json-parse-passing-variable-into-query-outfields/m-p/313666#M28842</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The following method worked for me:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var temp = '{"FeatureOutputFields":["SQMI", "STATE_NAME", "STATE_FIPS", "SUB_REGION", "STATE_ABBR"]}';&lt;/P&gt;&lt;P&gt;var temp1 = JSON.parse(temp);&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;query.outFields = temp1.FeatureOutputFields;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can test the application here: &lt;A href="http://jsfiddle.net/sd06c17w/" title="http://jsfiddle.net/sd06c17w/"&gt;Edit fiddle - JSFiddle&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 28 Jan 2015 13:25:55 GMT</pubDate>
    <dc:creator>NicholasHaney</dc:creator>
    <dc:date>2015-01-28T13:25:55Z</dc:date>
    <item>
      <title>JSON.parse - Passing variable into query.outfields.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/json-parse-passing-variable-into-query-outfields/m-p/313663#M28839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Friends:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to pass a variable into query.outfields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When it is hard coded it works. Coming in as an object.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;query.outFields = ["OBJECTID", "NAME"];&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Passing in the JSON variable does not work.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;query.outFields = JSON.parse(FieldNames);&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;STRONG&gt;&lt;SPAN class="objectBox-text objectBox"&gt;&lt;SPAN class="objectBox-text objectBox"&gt;"['OBJECTID', 'Name']" (value in query parameter through FFox)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I am getting a JSON error in the browser that says it cannot recognize the square bracket [ .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions on how to pass in JSON variables into query.output would be great.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Keith&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jan 2015 19:48:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/json-parse-passing-variable-into-query-outfields/m-p/313663#M28839</guid>
      <dc:creator>KeithAnderson</dc:creator>
      <dc:date>2015-01-27T19:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.parse - Passing variable into query.outfields.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/json-parse-passing-variable-into-query-outfields/m-p/313664#M28840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think the problem is the single quotes around &lt;EM&gt;OBJECTID&lt;/EM&gt; and&lt;EM&gt; Name.&lt;/EM&gt; JSON only allows double-quotes as string delimiters. You'll need to replace the single quote characters with double quotes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jan 2015 20:46:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/json-parse-passing-variable-into-query-outfields/m-p/313664#M28840</guid>
      <dc:creator>JeffJacobson</dc:creator>
      <dc:date>2015-01-27T20:46:02Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.parse - Passing variable into query.outfields.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/json-parse-passing-variable-into-query-outfields/m-p/313665#M28841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have tried everything I know without any luck.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"extentlatlon":"[-93.45,44.93]",  JSON.parse on that extent works.&lt;/P&gt;&lt;P&gt;"FeatureOutputFields":"[OBJECTID,NAME]"  JSON.parse on those fields do not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"FeatureOutputFields":"[“OBJECTID,NAME”]”    No go&lt;/P&gt;&lt;P&gt;"FeatureOutputFields":"[“OBJECTID”,”NAME”]”   No go&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the effort.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jan 2015 21:16:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/json-parse-passing-variable-into-query-outfields/m-p/313665#M28841</guid>
      <dc:creator>KeithAnderson</dc:creator>
      <dc:date>2015-01-27T21:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.parse - Passing variable into query.outfields.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/json-parse-passing-variable-into-query-outfields/m-p/313666#M28842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The following method worked for me:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var temp = '{"FeatureOutputFields":["SQMI", "STATE_NAME", "STATE_FIPS", "SUB_REGION", "STATE_ABBR"]}';&lt;/P&gt;&lt;P&gt;var temp1 = JSON.parse(temp);&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;query.outFields = temp1.FeatureOutputFields;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can test the application here: &lt;A href="http://jsfiddle.net/sd06c17w/" title="http://jsfiddle.net/sd06c17w/"&gt;Edit fiddle - JSFiddle&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Jan 2015 13:25:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/json-parse-passing-variable-into-query-outfields/m-p/313666#M28842</guid>
      <dc:creator>NicholasHaney</dc:creator>
      <dc:date>2015-01-28T13:25:55Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.parse - Passing variable into query.outfields.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/json-parse-passing-variable-into-query-outfields/m-p/313667#M28843</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Nic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will remember your effort!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jeff told me to try escape characters and I eventually got it going.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #666666; font-size: 10.5pt; font-family: 'Helvetica',sans-serif;"&gt;You'll need to escape the double quotes since the string is delimited by double quotes.&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG style="color: #666666;"&gt;{&lt;/STRONG&gt;&lt;/PRE&gt;&lt;PRE class="jive-pre"&gt;&lt;STRONG style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "FeatureOutputFields": "[\"OBJECTID,NAME\"]"&lt;/STRONG&gt;&lt;/PRE&gt;&lt;PRE class="jive-pre"&gt;&lt;STRONG style="color: #666666;"&gt;}&lt;/STRONG&gt;&lt;/PRE&gt;&lt;P&gt;This was the final result for me:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"FeatureOutputFields":"[\"OBJECTID\",\"NAME\"]"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Keith&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Jan 2015 14:19:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/json-parse-passing-variable-into-query-outfields/m-p/313667#M28843</guid>
      <dc:creator>KeithAnderson</dc:creator>
      <dc:date>2015-01-28T14:19:13Z</dc:date>
    </item>
  </channel>
</rss>

