import { fromJSON, getJsonType } from "@arcgis/core/geometry/support/jsonUtils.js";const { fromJSON, getJsonType } = await $arcgis.import("@arcgis/core/geometry/support/jsonUtils.js");- Since
- ArcGIS Maps SDK for JavaScript 4.0
Provides utility methods for working with ArcGIS JSON geometry objects.
Functions
| Name | Return Type | Object |
|---|---|---|
| | ||
| |
fromJSON
Creates a new instance of an appropriate Geometry class and initializes it with values from a JSON object
generated from an ArcGIS product. The object passed into the input json
parameter often comes from a response to a query operation in the REST API or a
toJSON()
method from another ArcGIS product. See the Using fromJSON()
topic in the Guide for details and examples of when and how to use this function.
- Signature
-
fromJSON (json: object | null | undefined): GeometryUnion | null | undefined
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| json | A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects. | |
- Returns
- GeometryUnion | null | undefined
Returns a new instance of an appropriate Geometry class.
getJsonType
Returns the type for a given geometry in the JSON format used by ArcGIS. This only applies to geometries that can be processed by the server.
- Signature
-
getJsonType (geometry: GeometryUnion | null | undefined): GeometryType | null | undefined
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The input geometry object. | |
- Returns
- GeometryType | null | undefined
Returns the Geometry.type as represented on the server.