2

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?

2
  • 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? Commented Feb 7, 2022 at 20:53
  • @Dondragmer Good call. I think you're probably right. Commented Feb 8, 2022 at 19:18

1 Answer 1

4

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.

1

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.