I have these two arrays:
String[] COLUMN_NAMES = { "row_number", "column_name", "column_value_string", "column_value_float", "blockId", "pipelineId" };
String[] Values = { "1", "Output", "Valid", "", "123sde-dfgr", "pipeline-sde34" };
Where the output I need to be is in a json format (replacing empty values in Values Array with null in the output):
{
"row_number": 1,
"column_name": "output",
"column_value_string": "Valid",
"column_value_float": null,
"blockId": "123sde-dfgr",
"pipelineId": "pipeline-sde34"
}
Here is the code:
Map<String,String> result = IntStream.range( 0,COLUMN_NAMES.length ).boxed()
.collect( Collectors.toMap( i->COLUMN_NAMES[i], i->Values[i] ) );