Source:
<code>private RowDataToJsonConverter createMapConverter( String typeSummary, LogicalType keyType, LogicalType valueType) { if (!LogicalTypeChecks.hasFamily(keyType, LogicalTypeFamily.CHARACTER_STRING)) { throw new UnsupportedOperationException( "JSON format doesn't support non-string as key type of map. " + "The type is: " + typeSummary); } final RowDataToJsonConverter valueConverter = createConverter(valueType); final ArrayData.ElementGetter valueGetter = ArrayData.createElementGetter(valueType); return (mapper, reuse, object) -> { ObjectNode node; if (reuse == null || reuse.isNull()) { node = mapper.createObjectNode(); } else { node = (ObjectNode) reuse; node.removeAll(); } MapData map = (MapData) object; ArrayData keyArray = map.keyArray(); ArrayData valueArray = map.valueArray(); int numElements = map.size(); for (int i = 0; i < numElements; i++) { boolean isFieldNameNull = keyArray.isNullAt(i); String fieldName = null; <START> if (isFieldNameNull) { <END> switch (mapNullKeyMode) { case LITERAL: fieldName = mapNullKeyLiteral; break; case DROP: continue; case FAIL: throw new RuntimeException("Map key is null, please have a check." + " You can setup null key handling mode to drop entry or replace with a no-null literal."); default: throw new RuntimeException("Unsupported map null key mode. Validator should have checked that."); } } else { fieldName = keyArray.getString(i).toString(); } Object value = valueGetter.getElementOrNull(valueArray, i); node.set(fieldName, valueConverter.convert(mapper, node.get(fieldName), value)); } return node; }; }</code><technical_language>simplify invoking keyArray.isNullAt(i) here</technical_language>

Target:
private RowDataToJsonConverter createMapConverter( String typeSummary, LogicalType keyType, LogicalType valueType) { if (!LogicalTypeChecks.hasFamily(keyType, LogicalTypeFamily.CHARACTER_STRING)) { throw new UnsupportedOperationException( "JSON format doesn't support non-string as key type of map. " + "The type is: " + typeSummary); } final RowDataToJsonConverter valueConverter = createConverter(valueType); final ArrayData.ElementGetter valueGetter = ArrayData.createElementGetter(valueType); return (mapper, reuse, object) -> { ObjectNode node; if (reuse == null || reuse.isNull()) { node = mapper.createObjectNode(); } else { node = (ObjectNode) reuse; node.removeAll(); } MapData map = (MapData) object; ArrayData keyArray = map.keyArray(); ArrayData valueArray = map.valueArray(); int numElements = map.size(); for (int i = 0; i < numElements; i++) { String fieldName = null; if (keyArray.isNullAt(i)) { switch (mapNullKeyMode) { case LITERAL: fieldName = mapNullKeyLiteral; break; case DROP: continue; case FAIL: throw new RuntimeException(String.format( "JSON format doesn't support to serialize map data with null keys. " + "You can drop null key entries or encode null in literals by specifying %s option.", JsonOptions.MAP_NULL_KEY_MODE.key())); default: throw new RuntimeException("Unsupported map null key mode. Validator should have checked that."); } } else { fieldName = keyArray.getString(i).toString(); } Object value = valueGetter.getElementOrNull(valueArray, i); node.set(fieldName, valueConverter.convert(mapper, node.get(fieldName), value)); } return node; }; }