Better way to map child json objects to Serenade model

17 views
Skip to first unread message

Sergey Makridenkov

unread,
Dec 19, 2013, 2:41:08 AM12/19/13
to seren...@googlegroups.com
Hi,

I want load JSON with child object to Serenade model.

My solution

mcycle_from_json = (json) ->
  mcycle = new Mcycle(json)

  mcycle.tngs = json['tngs'].map (tng_json) -> 
    tng = new Swim.Tng(tng_json)
    tng.series = tng_json['series'].map (serie_json) -> new Swim.Serie(serie_json)
    tng

Is any one use something better? 

Reply all
Reply to author
Forward
0 new messages