grouping by sid and pack them into array json.