Hi all,

Building off of a previous thread[1], I'm trying to parse a POST
request that contains JSON data. Specifically, I expect a JSON array
of JSON objects representing Packet model data and want to have a List
[Packet] at the end.

I am trying the following:
val packets = for {
        JSONPackets <- req.param("packets")
        packet <- JSONParser.parse(JSONPackets)
        nodeId <- packet.param("node")
        node <- nodeId.toLong
} yield {
        val packet = Packet.create.node(node)
        packet.save
        packet
}

The problem is that JSONParser.parse returns a List[Any], so packet is
of type Any. I can try to convert packet to a Map with
packet.asInstanceOf[Map[String, String]], but this seems to just push
my type problems to the next line of code. I'm having a hard time
getting to the point where I have the Map[String, String] from which I
know I can extract values to create Packets, so I would appreciate
suggestions on how to do this.

This all seems quite complicated and I wonder if I'm missing an easier
way to do this. Is JSONParse the way to go, or should I switch to
Joni's lift-json stuff? I'm using 1.1-M5 but would be willing to
switch to 1.1-SNAPSHOT...

Thanks for your help.

Peter Robinett

[1] 
http://groups.google.com/group/liftweb/browse_thread/thread/5ffe64492b0c19f2/c65424467bc99bbb
[2] http://groups.google.com/group/liftweb/msg/c0103375623f788f
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@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