how to save featurelayer into json by javascript in web app?

1412
2
Jump to solution
08-03-2021 04:05 AM
MichaelLev
Occasional Contributor III

ESRI Graphic has "toJson()" method, but Feature Layer has not such a methos. How do I save a feature layer into json text file?

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Frequent Contributor

You can query the features you're interested in, iterate them and run .toJSON() on each feature. There's no quick way to export all features to JSON though, due to stuff like server query limits. 

 

Oh and FeatureLayer queries return a FeatureSet, and that has a toJSON() method on it too. https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-FeatureSet.html

View solution in original post

0 Kudos
2 Replies
ReneRubalcava
Frequent Contributor

You can query the features you're interested in, iterate them and run .toJSON() on each feature. There's no quick way to export all features to JSON though, due to stuff like server query limits. 

 

Oh and FeatureLayer queries return a FeatureSet, and that has a toJSON() method on it too. https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-FeatureSet.html

0 Kudos
MichaelLev
Occasional Contributor III

@ReneRubalcava ,
I used the query to get a FeatureSet, and succeeded to save the feature layer to text and also to recreate it from that text.
Thank you very much!

0 Kudos