Select to view content in your preferred language

JSONUtils encode to string at 3.1

1659
2
02-06-2013 05:07 PM
AndrewThomas
Deactivated User
I am migrating a flex application from ArcGIS flex API 2.4 / Flex SDK 4.5 to API 3.1 / Flex SDK 4.6

After changing all the occurences of JSON.decode and JSON.encode to use JSONUtil.encode/decode (importing com.esri.ags.utils.JSONUtil; ) I am getting runtime errors while debugging.

The error message is:

Error: Unknown Property: 'dispatchResetEvent'.
 at mx.collections::ListCollectionView/http://www.adobe.com/2006/actionscript/flash/proxy::getProperty()
 at JSON$/stringifySpecializedToString()
 at JSON$/stringify()
 at com.esri.ags.utils::JSONUtil$/encode()
        at myProject.components::myProjectUserFavourites/UpdateFavouritesToServer()


where dispatchResetEvent is part of the inherited object of an MX:ArrayCollection that I'm trying to encode:

This worked fine at 2.4/4.5 but doesn't work at 3.1/4.6

Attached is the FlashBuilder Expression at the line that calls the encode where the error occurs:

var FavouritesJSON:String = JSONUtil.encode(ArrayOfAllFavourites.source);

Can anyone shed any light onto what might be the cause and or solution

Cheers

Andrew
Tags (2)
0 Kudos
2 Replies
DasaPaddock
Esri Regular Contributor
I'd try:

var FavouritesJSON:String = JSONUtil.encode(ArrayOfAllFavourites.toArray());
0 Kudos
AndrewThomas
Deactivated User
Thanks Dasa.

I would have thought these two were pretty much equivalent:

var FavouritesJSON:String = JSONUtil.encode(ArrayOfAllFavourites.source);
var FavouritesJSON:String = JSONUtil.encode(ArrayOfAllFavourites.toArray());

Regardless, neither worked as there was several nested array collections so I managed to pre-emptively alter those in other places before they ever got to this function. Those that I couldn't I had to manually parse the array collection and set the five properties. Not ideal but manageable in my case.

It's strange that this suddenly didn't handle it at 3.1 but was OK at 2.4.

Thanks

Andrew
0 Kudos