In ArcMap 10.7.1 (with an Oracle 18c SDE.ST_GEOMETRY polyline FC):
I want to use the Field Calculator (Python) in the Attribute Table to get a feature's JSON text.
Pre-Logic Script Code:
----------------------
def wJson(shp):
pnts = shp.JSON
return str(pnts)
Expression: JSON =
----------------------
wJson( !SHAPE! )
When I run that field calculation, I don't get an error, but it doesn't populate a value in the field (remains null).
What am I doing wrong? How can I get that field calculation to return a value?
Best Answer
Try the actual Field Calculator tool and run the workflow as it'll log warnings (which you don't see when doing from the right click menu). When I run that, I get a warning that one of the values cannot be written to the field and returns null
It fails because my field is the default size of 255 characters, but the output JSON for me is over 600 characters. Thus, my fix, would be to either truncate the JSON going into the field or create a new, larger text field.