Concatenate JsObj objects

View: New views
2 Messages — Rating Filter:   Alert me  

Concatenate JsObj objects

by GA-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello guys,

is it possible to concatenate JsObj objects?

Right now I have several JsonResponse calls depending on some  
conditions. I am building the responses including some error codes and  
different components.

I would like to build the answer part by part and concatenate the  
pieces at the end of the method in only one call to JsonResponse.

Here an example:

JsonResponse(JsObj("a" -> 1, "b"->2))

Would it be possible to have something like:

val response = JsObj("a" -> 1)

val response1=JsObj("b" -> 2)

then JsonResponse(JsObj(reponse ,response1))

A line exactly like this one gives a compilation error. I know I need  
to write it differently but I do not know how. Any suggestions?

Thanks in advance,

GA


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to liftweb@...
To unsubscribe from this group, send email to liftweb+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Concatenate JsObj objects

by Ross Mellgren-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


var responses: List[(String, JsExp)] = Nil

responses ::= "a" -> 1
responses ::= "b" -> 2

JsonResponse(JsObj(responses: _*))

If you really want to concatenate JsObj, you can do that too

val response1 = JsObj("a" -> 1)
val response2 = JsObj("b" -> 2)

JsonResponse(response1 +* response2)

-Ross

On Nov 9, 2009, at 1:19 PM, GA wrote:

>
> Hello guys,
>
> is it possible to concatenate JsObj objects?
>
> Right now I have several JsonResponse calls depending on some
> conditions. I am building the responses including some error codes and
> different components.
>
> I would like to build the answer part by part and concatenate the
> pieces at the end of the method in only one call to JsonResponse.
>
> Here an example:
>
> JsonResponse(JsObj("a" -> 1, "b"->2))
>
> Would it be possible to have something like:
>
> val response = JsObj("a" -> 1)
>
> val response1=JsObj("b" -> 2)
>
> then JsonResponse(JsObj(reponse ,response1))
>
> A line exactly like this one gives a compilation error. I know I need
> to write it differently but I do not know how. Any suggestions?
>
> Thanks in advance,
>
> GA
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to liftweb@...
To unsubscribe from this group, send email to liftweb+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---