Cleanup: reorganize getCastCodeFromJson, preparing indentation
refactoring.