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).

enter image description here

What am I doing wrong? How can I get that field calculation to return a value?

  • 1
    This is independent of the answer, but according to the documentation you found, the JSON property is already a string. So does calling str() on it have any effect?
    – Cowirrie
    Commented Feb 7, 2022 at 20:53
  • @Dondragmer Good call. I think you're probably right.
    – User1974
    Commented Feb 8, 2022 at 19:18

1 Answer 1


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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.