JsArray((m map { case (k, (v1, v2)) => JsObj(k -> JsArray(v1,v2)) }): _*)

-------------------------------------
Ross Mellgren<dri...@gmail.com> wrote:

Oh sorry, my bad. I think it would be better to do m.toSeq.map ... instead of 
m.elements.collect.map ...

-Ross

On Jan 14, 2010, at 3:14 PM, martinsema...@googlemail.com wrote:

> Thanks
> .elements provides an Iterator. I have added collect to get a Seq and
> now it works:
> 
> JsArray(
>           (m.elements.collect.map
>                       { case (k, v) => JsObj(k -> JsArray(v._1, v._2)) }
>               : _*)
> 
>         )
> 
> Martin
> 
> On 14 Jan., 18:32, Ross Mellgren <dri...@gmail.com> wrote:
>> Haven't compiled or tested it, but here's something that should work:
>> 
>> JsArray(m.elements.map { case (k, v) => JsObj(k -> JsArray(v._1, v._2)) }: 
>> _*)
>> 
>> -Ross
>> 
>> On Jan 14, 2010, at 11:25 AM, martinsema...@googlemail.com wrote:
>> 
>>> Hi
>>> i need some help with a conversation from HashMap to JsArray.
>> 
>>> I have something like:
>> 
>>> var m = new HashMap[String, (Int,Int)]
>> 
>>> and i want to use it in JE.Call as an argument. I think it has to be
>>> converted to a JsArray. Some kind of map or fold should fit here, but
>>> i dont know how to do it.
>>> The JSON should look like [{"str1":[1,2]},{"str2":[1,2]}] or any
>>> similar.
>> 
>>> Thanks for your tipps. (maybe its more a scala issue but i try it :))
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "Lift" group.
>>> To post to this group, send email to lift...@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> liftweb+unsubscr...@googlegroups.com.
>>> For more options, visit this group 
>>> athttp://groups.google.com/group/liftweb?hl=en.
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Lift" group.
> To post to this group, send email to lift...@googlegroups.com.
> To unsubscribe from this group, send email to 
> liftweb+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/liftweb?hl=en.
> 
> 

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


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


Reply via email to