On Fri, Jul 10, 2009 at 1:44 AM, Jeppe Nejsum Madsen <[email protected]>wrote:
> > "marius d." <[email protected]> writes: > > > Please take a look on JsObj. > > That's what I'm using now and it's a pain: > > def generateOptions = JsObj( > ("title", "My title"), > ("series", JsArray(JsObj(("Label","MyLabel")))), > ("seriesColors", JsArray("#000000","#cccccc")), > ("axes", JsObj( > ("xaxis", JsObj( > ("renderer", JsVar("$.jqplot.CategoryAxisRenderer")), > ("ticks", JsArray(data.flatMap(series => > {series.labels.map(v => v.toString)}) : _*)) > )), > ("yaxis", JsObj( > ("min", 0), > ("tickOptions", JsObj( > ("formatString", "%d") > )) > )) > )), > ("seriesDefaults", JsObj( > ("renderer", JsVar("$.jqplot.BarRenderer")), > ("rendererOptions", JsObj( > ("barDirection", "horizontal"), > ("barPadding", 8), > ("barMargin",20), > ("barWidth", 20) > )) > > ))) > Looks like Lisp... :-) In all seriousness, one of the pieces of Goat Rodeo (http://goatrodeo.organd Goat Rodeo will become part of Lift once GR is stable) is objects that will know how to serialize themselves as JSON. So, you'll get type safety and bi-direction serialization. In the mean time, I think Marius has some stuff in Record that also does bi-directional JSON. > > > But what is your exact use case? ... generate JSON constructs from > > Scala and send then to browser? > > Yes, I want the above JSON object (which is just a subset of the full > capabilities) to be generated in Scala, so I: > > - will get typechecking > - Don't have to remember field names > - Can't get autocompletion on valid values for things like > - e.g. barDirection > > /Jeppe > > > > > > > -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---
