javascript - coffeescript - manipulating json -


This is just the logic issue, if I have the data:

  [From: User A ', From:' User B '}, From:' User A ', From:' User C '}, {From:' User B ', to:' User D '}, {to:' User C 'For:' User D '}, from:' User C ', to:' User D '}]  

and I need to do that data to do the herring :

  [to: 'User A', for: ['User B ',' User C ']}, From:' User B ', From: [' User D ']}, {to:' User C ': [' User D ']}]  

I used this code:

  result = [] objTemp = obj = [] Obj.map (o) - & gt; If o From oyrop from piĆ¹ush = [] objTemp.map (oo) - & gt; If oo.from o.from and oo.to do not have to do oo.to temp = by: o.from: result.push temp  

but the result That is not what I hope, from the same 'is' in the same:

  [[to:' User A ', from: [' user b ',' user c ']}, [User D']}, from: 'User C', from: ['User D', 'User D'] & lt; - Problem}]  

How do you guys decide to use it using coffeepllip?

Here's how I can do it:

  res = [] Obj.map (o) - & gt; When R.O. for R in R Resigns from From Return (RTPUUTTO.TO in R.T.O.): From O, From: [O.ToO]  

Comments