Cast value to str only if it is an int

Previous set up would fail with recursive structures. Better to do it
this way.