Symbology JSON Creation

1109
1
07-23-2019 12:01 PM
KrisFoster
New Contributor III

Is there an easy way to generate the JSON for a symbol renderer.  For example, can I automatically generate the symbol JSON from a layer file for symbology that we have already defined via ArcMap?  

I can update the renderer for a loaded FeatureLayer with something similar to the following.

Renderer ren = Renderer.FromJson(File.ReadAllText(symbolJson));

loadedLayer.Renderer = ren;

Symbol JSON is similar to the following

{
"type": "uniqueValue",
"field1": "SUBTYPECD",
"field2": "WORKFUNCTION",
"field3": null,
"defaultSymbol": {
"type": "esriSLS",
"style": "esriSLSSolid",
"color": [
156,
156,
156,
255
],
"width": 1
},
"defaultLabel": "<all other values>",
"uniqueValueInfos": [
{
"symbol": {
"type": "esriSLS",
"style": "esriSLSSolid",
"color": [
0,
0,
0,
255
],
"width": 0.5
},
"value": "1,30",
"label": "Primary Bus Bar, In Service",
"description": ""
},
{
"symbol": {
"type": "esriSLS",
"style": "esriSLSSolid",
"color": [
0,
0,
0,
255
],
"width": 0.5
},
"value": "1,5",
"label": "Primary Bus Bar, In Service",
"description": ""
},
{
"symbol": {
"type": "esriSLS",
"style": "esriSLSSolid",
"color": [
0,
0,
0,
255
],
"width": 1
},
"value": "2,30",
"label": "Secondary Bus Bar, In Service",
"description": ""
},
{
"symbol": {
"type": "esriSLS",
"style": "esriSLSSolid",
"color": [
0,
0,
0,
255
],
"width": 1
},
"value": "2,5",
"label": "Secondary Bus Bar, In Service",
"description": ""
},
{
"symbol": {
"type": "esriSLS",
"style": "esriSLSSolid",
"color": [
255,
0,
0,
255
],
"width": 1
},
"value": "1,0",
"label": "Primary Bus Bar, Proposed - Install",
"description": ""
},
{
"symbol": {
"type": "esriSLS",
"style": "esriSLSSolid",
"color": [
255,
0,
0,
255
],
"width": 0.5
},
"value": "2,0",
"label": "Secondary Bus Bar, Proposed - Install",
"description": ""
}
],
"fieldDelimiter": ","
}

1 Reply
NathanRyan
New Contributor

I have this question too.

0 Kudos