Database

[{"pId":12345,"charges":{"key1":"10.0,11.0,12.0,13.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0","key2":"22.5%,12.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%","key3":"271.95,371.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,394.45,271.95,394.45"}}]

Query

db.collection.aggregate([{"$project":{pId:1,"charges":{"$map":{"input":{"$objectToArray":"$charges"},in:{K:"$$this.k",v:{"$split":["$$this.v",","]}}}}}},{"$project":{pId:1,charges:{"$arrayToObject":{$map:{input:"$charges",in:{k:"$$this.K",v:{"$reduce":{"input":{"$map":{/**input array of index to fetch values*/"input":[0,2],"as":"index","in":{"$arrayElemAt":["$$this.v","$$index"]}}},"initialValue":"","in":{"$concat":["$$value",{"$cond":[{"$gt":["$$value",""]},",",""]},"$$this"]}}}}}}}}}])

Result