public ArrayList < HashMap < String , String > > normalizeSoilLayers ( ArrayList < HashMap < String , String > > soilsData ) { HashMap < String , String > referenceSoil ; ArrayList < HashMap < String , String > > newSoilsData ; referenceSoil = soilsData . get ( 0 ) ; newSoilsData = new ArrayList < HashMap < String , String > > ( ) ; if ( referenceSoil != null ) { for ( HashMap < String , String > currentSoil : soilsData ) { // create a new soil with reference parameters HashMap < String , String > fullCurrentSoil = new HashMap < String , String > ( referenceSoil ) ; for ( String key : referenceSoil . keySet ( ) ) { if ( currentSoil . containsKey ( key ) ) { fullCurrentSoil . put ( key , currentSoil . get ( key ) ) ; } } newSoilsData . add ( fullCurrentSoil ) ; } } return newSoilsData ; }
Fill each layer with all parameters . In the json structure when a parameter value is missing we must take the value of the previous layer .