atom feed7 messages in com.googlegroups.liftwebRe: [lift] Re: JSON builder
FromSent OnAttachments
MariusApr 5, 2008 2:45 am 
MariusApr 5, 2008 5:54 am 
David PollakApr 5, 2008 5:59 am 
MariusApr 5, 2008 6:06 am 
MariusApr 6, 2008 12:02 am 
David PollakApr 6, 2008 3:11 pm 
MariusApr 6, 2008 10:35 pm 
Subject:Re: [lift] Re: JSON builder
From:David Pollak (feed@gmail.com)
Date:Apr 6, 2008 3:11:32 pm
List:com.googlegroups.liftweb

On Sun, Apr 6, 2008 at 12:02 AM, Marius <mari@gmail.com> wrote:

I've re-factored a bit the code a made it accept any JsExp, like:

val json = ("name" -> "Doe") ~ ("phone" -> "1231231231") ~ ("title" -> "Mr.") ~ ("rule" -> AnonFunc(JsReturn(ValById("myField"))))

this yields the following JSon:

{'name' : 'Doe', 'phone' : '1231231231', 'title' : 'Mr.', 'rule' : function() {return document.getElementById('myField').value;}}

JsReturn is not included yet in the lift js layer but I'd like to since it is missing, and currently if we want to return from an anonymous JS function we have to type it manually. JsResponse looks like:

Yeah... adding it would be great. Maybe we can set up a wiki page to record the JavaScript that people are hand-coding and just go through an turn it into stuff in JsCommands. WDYT?

object JsReturn { def apply(in: JsExp): JsExp = JsRaw("return " + in.toJsCmd) }

Thoughts are more than welcomed !