Firstly, you need add the values of the fields in rowFields in order into keys. Then add the values of the fields in columnFields in order. If some field value is null, JUST add null into array and DO NOT remove it. ou should keep the count of the keys array same as the count of the fields in rowFields and columnFields.