HOW TO
JavaScript Object Notation (JSON) is a standard text-based format that represents structured data based on the JavaScript object syntax. Web map and web application data can be saved as JSON files and stored on the machine to ease data transfer and recovery.
Use the workflows highlighted in this article to download the web maps and web applications as JSON files.
Retrieve and save the JSON data for a specific web map or web application
from arcgis import gis from arcgis.gis import GIS import json
gis = GIS("https://arcgis.com", "Username", "Password") print("Connected.")
web_map = gis.content.get("<item ID>") #Edit the item ID jsonData=web_map.get_data(try_json=True)
with open (r"<Folder Location>", "w") as file_handle: #Edit the folder location file_handle.write(json.dumps(jsonData)) print("Completed")
The following code block demonstrates the full script.
from arcgis import gis from arcgis.gis import GIS import json gis = GIS("https://arcgis.com", "Username", "Password") print("Connected.") web_map = gis.content.get("0424sdgshhfjtRFSb9469ef") jsonData=web_map.get_data(try_json=True) with open (r"C:\Users\USER\Desktop\TEST\testingWebMap.json", "w") as file_handle: file_handle.write(json.dumps(jsonData)) print("Completed")
Retrieve and save all the JSON data listed under a specific owner in ArcGIS Online
from arcgis import gis from arcgis.gis import GIS import json
gis = GIS("https://arcgis.com", "Username", "Password") print("Connected.")
x=0 my_item = gis.content.search(query="owner:<Owner Name>",item_type="Web Map") #Edit the owner's name and the item_type parameter print(my_item)
for item in my_item: my_item = gis.content.search(query="owner:<Owner Name>",item_type="Web Map")[x] #Edit the owner's name and the item_type parameter item = my_item.get_data(try_json=True) with open (r"<Folder Location", "w") as file_handle: #Edit the folder location file_handle.write(json.dumps(item)) x=x+1 print("Completed")
The following code block demonstrates the full script.
from arcgis import gis from arcgis.gis import GIS import json gis = GIS("https://arcgis.com", "Username", "Password") print("Connected.") x=0 my_item = gis.content.search(query="owner:USER",item_type="Web Map") print(my_item) for item in my_item: my_item = gis.content.search(query="owner:USER",item_type="Web Map")[x] item = my_item.get_data(try_json=True) with open (r"C:\Users\USER\Desktop\TEST\testingWebMap.json", "w") as file_handle: file_handle.write(json.dumps(item)) x=x+1 print("Completed")
Article ID: 000027813
Get help from ArcGIS experts
Download the Esri Support App