I am having issues with importing a .json file from a runtime FeatureCollection to ArcPro or ArcMap. Is this a supported workflow? I have the .json file attached that is not working.
I am using ArcGIS Runtime SDK for Android 100.6.0.
When reviewing the suggested solution when importing it to ArcPro I can confirm that the .json file has items listed (geometryType, spatialReference, fields, and features (with geometry and attributes) property):
Error in ArcPro:
001558: Error parsing .json file <value>.
Description
The JSON structure does not conform to ESRI-JSON standard for feature sets.
Solution
Review the JSON structure in the input file. The JSON must have at least the geometryType, spatialReference, fields, and features (with geometry and attributes) property.
File outFile <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">File</SPAN><SPAN class="punctuation token">(</SPAN>FILE_PATH<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>featureCollectionTable<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getTotalFeatureCount</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">></SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
Iterable<SPAN class="operator token"><</SPAN>FeatureCollectionTable<SPAN class="operator token">></SPAN> featureCollectionTables <SPAN class="operator token">=</SPAN> Arrays<SPAN class="punctuation token">.</SPAN><SPAN class="token function">asList</SPAN><SPAN class="punctuation token">(</SPAN>featureCollectionTable<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
FeatureCollection featureCollection <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">FeatureCollection</SPAN><SPAN class="punctuation token">(</SPAN>featureCollectionTables<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
String jsonString <SPAN class="operator token">=</SPAN> featureCollection<SPAN class="punctuation token">.</SPAN><SPAN class="token function">toJson</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//saving file....</SPAN>
FileOutputStream out <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">FileOutputStream</SPAN><SPAN class="punctuation token">(</SPAN>outFile<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">byte</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN> bytes <SPAN class="operator token">=</SPAN> jsonString<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getBytes</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
out<SPAN class="punctuation token">.</SPAN><SPAN class="token function">write</SPAN><SPAN class="punctuation token">(</SPAN>bytes<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
out<SPAN class="punctuation token">.</SPAN><SPAN class="token function">flush</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
out<SPAN class="punctuation token">.</SPAN><SPAN class="token function">close</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Thanks,