Jun-30-2019, 05:08 AM
I have a list like:
- if m is good, g should have group of dictionary where n matches
- if m is bad, b should have group of dictionary where n matches
So, here I have to group them by n and with good and bad property. Hope this is clear.
Please note the value of n is generated with timestamp. I have shown here 1,2,3.. just for ease.
result = [ { "name: "John", "m": "good", "n": 1 }, { "name": 'Alina', "m": "good", "n": 1 }, { "name": "Olivia", "m": "bad", "n": 2 }, { "name": "Ruby", "m": "bad", "n": 2 }, ... ]I want to convert it into like this:
result = [ { // n is 1 "g": [ { "name": "John", "n": 1 }, { "name":"Alina", "n": 1 } ], "b": [ { "name": "...", "n": 1 }, { "name": "...", "n": 1 } ] }, { // n is 2 "g": [...], "b": [...] }, { // n is 3 // ... } ]What I'm trying to achieve here is as follows:
- if m is good, g should have group of dictionary where n matches
- if m is bad, b should have group of dictionary where n matches
So, here I have to group them by n and with good and bad property. Hope this is clear.
Please note the value of n is generated with timestamp. I have shown here 1,2,3.. just for ease.