<?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 JSON.encode of an date object in ArcGIS API for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/json-encode-of-an-date-object/m-p/568123#M12823</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for the solution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm seeing how simple it is to implements.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We are having already a lot of complex objects using date fields which where transferred with BlazeDS. We are now switching to a customSOE-Rest enabled communication. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wouldn't it be possible to add this json-date-conversion directly to your JSON.encode method?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So we don't need to edit all our business classes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Tom&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 17 Apr 2010 04:49:26 GMT</pubDate>
    <dc:creator>TomSchuller</dc:creator>
    <dc:date>2010-04-17T04:49:26Z</dc:date>
    <item>
      <title>JSON.encode of an date object</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/json-encode-of-an-date-object/m-p/568119#M12819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;running a JSON.encode on a Date object, it's generating me a non-compatible JSON-format to communicate with the AGS-Rest-api.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Here my JSON string:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;{"secondsUTC":14,"date":16,"dayUTC":5,"minutes":33,"fullYear":2010,"millisecondsUTC":493,"month":3,"monthUTC":3,"seconds":14,"minutesUTC":33,"hours":20,"timezoneOffset":-120,"milliseconds":493,"hoursUTC":18,"dateUTC":16,"fullYearUTC":2010,"day":5,"time":1271442794493}&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The format used in the AGS-Rest api is the date expressed in ms started from 1 Jan 1970, like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;A href="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/Since_1970/MapServer/0/query?text=&amp;amp;geometry=&amp;amp;geometryType=esriGeometryEnvelope&amp;amp;inSR=&amp;amp;spatialRel=esriSpatialRelIntersects&amp;amp;relationParam=&amp;amp;objectIds=1&amp;amp;where=&amp;amp;time=&amp;amp;returnIdsOnly=false&amp;amp;returnGeometry=true&amp;amp;maxAllowableOffset=&amp;amp;outSR=&amp;amp;outFields=*&amp;amp;f=pjson" rel="nofollow noopener noreferrer" target="_blank"&gt;http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/Since_1970/MapServer/0/query?text=&amp;amp;geometry=&amp;amp;geometryType=esriGeometryEnvelope&amp;amp;inSR=&amp;amp;spatialRel=esriSpatialRelIntersects&amp;amp;relationParam=&amp;amp;objectIds=1&amp;amp;where=&amp;amp;time=&amp;amp;returnIdsOnly=false&amp;amp;returnGeometry=true&amp;amp;maxAllowableOffset=&amp;amp;outSR=&amp;amp;outFields=*&amp;amp;f=pjson&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is this a bug or what is wrong in my code below?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using the com.esri.ags.utils.JSON, so it should generate the correct format.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is still present in the latest beta library: &lt;/SPAN&gt;&lt;STRONG&gt;agslib-2.0BetaUpdate2-2010-04-07&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Tom&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import com.esri.ags.utils.JSON;
import mx.controls.Alert;
function testJSON():void {
 var myDate:Date= new Date();
 var jsonDateString:String = JSON.encode(myDate);
 Alert.show(jsonDateString);
}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:28:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/json-encode-of-an-date-object/m-p/568119#M12819</guid>
      <dc:creator>TomSchuller</dc:creator>
      <dc:date>2021-12-12T00:28:28Z</dc:date>
    </item>
    <item>
      <title>JSON.encode of an date object</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/json-encode-of-an-date-object/m-p/568120#M12820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You'll need to set the Date's time property in the object you're encoding.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
var now:Date = new Date();
var result:String = JSON.encode({ "date": now.time });
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:28:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/json-encode-of-an-date-object/m-p/568120#M12820</guid>
      <dc:creator>DasaPaddock</dc:creator>
      <dc:date>2021-12-12T00:28:31Z</dc:date>
    </item>
    <item>
      <title>JSON.encode of an date object</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/json-encode-of-an-date-object/m-p/568121#M12821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for your answer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Taking the case that I have a complex object which contains some date fields.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I will pass my complex object to the &lt;/SPAN&gt;&lt;STRONG&gt;JSON.encode&lt;/STRONG&gt;&lt;SPAN&gt; method.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How can I do this (see example below)?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Tom&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import com.esri.ags.utils.JSON; 
import mx.controls.Alert;
function testJSON():void {
 var myObject:Object = new Object();
 myObject["label"]="test";
 myObject["myDate"]= new Date();
 var jsonDateString:String = JSON.encode(myObject);
 Alert.show(jsonDateString);
}
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:28:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/json-encode-of-an-date-object/m-p/568121#M12821</guid>
      <dc:creator>TomSchuller</dc:creator>
      <dc:date>2021-12-12T00:28:34Z</dc:date>
    </item>
    <item>
      <title>JSON.encode of an date object</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/json-encode-of-an-date-object/m-p/568122#M12822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import com.esri.ags.utils.JSON; 
import mx.controls.Alert;
function testJSON():void {
 var myObject:Object = new Object();
 myObject["label"]="test";
 myObject["myDate"]= new Date().time;
 var jsonDateString:String = JSON.encode(myObject);
 Alert.show(jsonDateString);
}
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:28:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/json-encode-of-an-date-object/m-p/568122#M12822</guid>
      <dc:creator>DasaPaddock</dc:creator>
      <dc:date>2021-12-12T00:28:36Z</dc:date>
    </item>
    <item>
      <title>JSON.encode of an date object</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/json-encode-of-an-date-object/m-p/568123#M12823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for the solution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm seeing how simple it is to implements.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We are having already a lot of complex objects using date fields which where transferred with BlazeDS. We are now switching to a customSOE-Rest enabled communication. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wouldn't it be possible to add this json-date-conversion directly to your JSON.encode method?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So we don't need to edit all our business classes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Tom&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Apr 2010 04:49:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/json-encode-of-an-date-object/m-p/568123#M12823</guid>
      <dc:creator>TomSchuller</dc:creator>
      <dc:date>2010-04-17T04:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.encode of an date object</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/json-encode-of-an-date-object/m-p/568124#M12824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, we'll update our encoder to look for Dates and encode them using their time value.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Apr 2010 19:50:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/json-encode-of-an-date-object/m-p/568124#M12824</guid>
      <dc:creator>DasaPaddock</dc:creator>
      <dc:date>2010-04-30T19:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.encode of an date object</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/json-encode-of-an-date-object/m-p/568125#M12825</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Great, thanks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Tom&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 01 May 2010 05:29:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/json-encode-of-an-date-object/m-p/568125#M12825</guid>
      <dc:creator>TomSchuller</dc:creator>
      <dc:date>2010-05-01T05:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.encode of an date object</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/json-encode-of-an-date-object/m-p/568126#M12826</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm also running into this issue in a .NET/winforms app that updates a feature service using REST. Since there's no JSON encoding built-in to .NET, creating a JSON-compatible date is cumbersome. Have you given any thought to allowing standardized date strings for these kinds of parameters?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 May 2010 15:50:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/json-encode-of-an-date-object/m-p/568126#M12826</guid>
      <dc:creator>MarkDeaton</dc:creator>
      <dc:date>2010-05-03T15:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.encode of an date object</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/json-encode-of-an-date-object/m-p/568127#M12827</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Yes, we'll update our encoder to look for Dates and encode them using their time value.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How do I implement the JSON.encode in my flex project?&amp;nbsp;&amp;nbsp; The data field that the REST returns is Thu Jun 03 18:16:36 CDT 2010 and I'd like it to be Jun 03, 2010 18:13.&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jun 2010 21:47:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/json-encode-of-an-date-object/m-p/568127#M12827</guid>
      <dc:creator>JeffPerkins</dc:creator>
      <dc:date>2010-06-09T21:47:38Z</dc:date>
    </item>
  </channel>
</rss>

