Select to view content in your preferred language

FeatureSet To/From JSON Missing

2644
5
06-28-2010 09:41 AM
RyanCooney
Occasional Contributor
Has anyone found a way to create a FeatureSet from a JSON string in the Silverlight API?

The Javascript and Flex APIs expose this functionality but the SL/WPF APIs explicitly hide it. I've resorted to manually assembling a JSON string from a FeatureSet, but you can't go the other way. The FeatureSet class contains private setters that prevent you from actually creating a useable object in code.

ESRI, please make your To/From JSON methods standard across all the APIs!

--Ryan
0 Kudos
5 Replies
dotMorten_esri
Esri Notable Contributor
Could you share some insight into why you need this?
0 Kudos
RyanCooney
Occasional Contributor
Thanks for the reply. Basically I need to be able to serialize and pass feature data between client and server applications. Rather than creating a custom object to do this (in each of the 3 APIs) I would like to use a FeatureSet because it already contains everything I need, and it will be familiar to other client API developers.

Just as "QueryTask.ExecuteAsync(...)" will get you a FeatureSet it would be ideal if "MyServerTask.ExecuteAsync(...)" could do the same. Same pattern - same kind of result.
0 Kudos
dotMorten_esri
Esri Notable Contributor
OK gotcha'. So using a WCF service is not a solution? Basically you wouldn't even have to worry about serialization at all (not to mention its a more efficient serialization used on the hood). See http://blogs.esri.com/Dev/blogs/silverlightwpf/archive/2010/03/11/Sending-geometry-between-Silverlig...

Currently we don't have any FeatureSet serializers in the Silverlight API (not even internally - that's only a deserializer).
0 Kudos
RyanCooney
Occasional Contributor
Yes, I could pass geometries and attributes with a WCF service, but...


  1. I still can't create a complete/valid FeatureSet in Silverlight from that data (private setters prevent this) so I'd be stuck with a FeatureSet-like custom object

  2. WCF would require special handling of the service and contract in all three client APIs (easy for Silverlight but less so for the others)

  3. I'm trying to expose the FeatureSet through a REST API so it is not really a good fit for my particular project


The function I'm after is available in the other APIs and works beautifully. I'd love to see it in Silverlight as well.
http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/FeatureSet.html#convertFromJSON()
http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/arcgis/help/jsapi/featureset.htm#Fea...

Thanks
0 Kudos
BrentStevener
Deactivated User
I am trying to create a client side 'Area Picker' control and thought I could just take the JSON string and load it into a featureset with Silverlight, eliminating the need to take a trip to the server in order to get feature information. However, I hit a roadblock with the Silverlight API since the FromJSON method is missing. In theory, it sounded great, but now I have to rethink the whole solution.

***EDIT!!***
I was testing it in an older 2.0 API project. I referenced the newer 2.1 API dlls and the FromJSON method is there! *whew*
0 Kudos