jsonUtils

AMD: require(["esri/symbols/support/jsonUtils"], (symbolJsonUtils) => { /* code goes here */ });
ESM: import * as symbolJsonUtils from "@arcgis/core/symbols/support/jsonUtils.js";
Object: esri/symbols/support/jsonUtils
Since: ArcGIS Maps SDK for JavaScript 4.0

Provides a utility method used to deserialize a JSON symbol object returned by the REST API.

Method Overview

Name Return Type Summary Object

Creates a new instance of an appropriate Symbol class and initializes it with values from a JSON object generated from an ArcGIS product.

jsonUtils

Method Details

fromJSON

Method
fromJSON(json){Symbol}

Creates a new instance of an appropriate Symbol 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.

When you create a MarkerSymbol, SimpleMarkerSymbol or PictureMarkerSymbol from a JSON object, you may specify a property angle to rotate the symbol. Be aware that the angle in the JSON is different from MarkerSymbol.angle. The angle in the JSON follows the traditional ArcGIS specification and is rotated counter-clockwise, whereas the angle in the symbol is rotated clockwise.

Parameter
json Object

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
Type Description
Symbol Returns a new instance of an appropriate Symbol class.
Example
// The angle=-30 in the JSON will create a symbol rotated -30 degrees counter-clockwise; that is,
// 30 degrees clockwise, which symbol.angle=30 would also produce.
let symbol = jsonUtils.fromJSON({
   "angle": -30,
   "xoffset": 0,
   "yoffset": 0,
   "type": "esriPMS",
   "url": "http://www.esri.com/careers/profiles/~/media/Images/Content/graphics/icons/socialmedia/pinterest1.png",
   "width": 18,
   "height": 18
});

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.