As part of learning, i was tried the below code snippets.
func ASNGroup(asn []map[string]interface{}) bool {
eachgroup := make([][]map[string]interface{}, 0)
for i := range asn {
for _, v := range asn[i] {
// How to filter the based on Key based on the below filter i should group the above asn array maps.
asn[i]["ID"]
}
}
fmt.Println(eachgroup)
return true
}
Please help me in code and Yes i avoided struct because i m preparing the asn object based on the xlsx sheet uploaded. Yes, i know this is the mandatory key so that i can hard code this key to filter. I understand it is not as easy than javascript. for writing functions i understand there should be some return initialization i initialized dummy bool for to avoid errors.
please don't deviate the issue, with suggestions
Understand and please help in logic to group something like this [[],[]].
this is the below example of []map[string]interface{}
[{"id":"1","seperator":"B","code":"twenty1"},
{"id":"2","seperator":"A","code":"twenty2"},
{"id":"3","seperator":"B","code":"twenty3"}]
seperator is the key inside object to seperate the objects.
{"B" : [{"id":"1","seperator":"B","code":"twenty1"},
{"id":"3","seperator":"B","code":"twenty3"}]
, "A" : [{"id":"2","seperator":"A","code":"twenty2"}]}