Thanks Jeppe and Naftoli,
i now use :
JsArray((m.toList map { case (k, (v1, v2)) => JsObj(k -> JsArray
(v1,v2)) }): _*)
as Naftoli suggested. I still need toList. I think this is most
readable.
Martin
On 14 Jan., 22:15, Naftoli Gugenheim <[email protected]> wrote:
> JsArray((m map { case (k, (v1, v2)) => JsObj(k -> JsArray(v1,v2)) }): _*)
>
> -------------------------------------
>
> Ross Mellgren<[email protected]> 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, [email protected] 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 <[email protected]> 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, [email protected] 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 [email protected].
> >>> To unsubscribe from this group, send email to
> >>> [email protected].
> >>> 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 [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> 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 [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.