system.mes.location.exportAsJson
Description
Exports all or selected Locations as a JSON string (UTF-8 encoded).
Streams location data from the database and formats it as a JSON string, including a header row.
When idsOrPaths is omitted, all locations are exported.
Permissions
This method requires the LOCATION.READ.GET permission.
Syntax
system.mes.location.exportAsJson()
system.mes.location.exportAsJson(idsOrPaths=["Enterprise/Site/Line1"])
Parameters
| Parameter | Type | Nullable | Description |
|---|---|---|---|
idsOrPaths | String[] | Yes | The ids or paths of the locations to export. Omit to export all. |
Returns
All locations as a JSON string (UTF-8 encoded).
Code Examples
Perspective
jsonString = system.mes.location.exportAsJson()
system.perspective.download("locations.json", jsonBytes)
Script Console
jsonString = system.mes.location.exportAsJson()
path = system.file.saveFile("locations.json")
if path is not None:
system.file.writeFile(path, jsonString)