Simplify error cases in _print_json_for_struct