As the guy that wrote (and still maintains) the JSON Parser in the Scala
core lib, I second David's opinion. The Scala JSON parser was intended to do
two things:

1. Show how to write parsers using the combinator library
2. Be a functional parser of JSON

The stuff that Joni is doing doesn't do #1, but it blows the Scala JSON
parser away in terms of performance and functionality.

Derek

On Fri, Oct 2, 2009 at 6:26 AM, David Pollak
<[email protected]>wrote:

> Peter,
>
> I'd suggest using the stuff in lift-json.  It's a much faster, richer way
> to use JSON.
>
> Thanks,
>
> David
>
>
> On Thu, Oct 1, 2009 at 4:31 PM, Peter Robinett <[email protected]>wrote:
>
>>
>> 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
>>
>>
>
>
> --
> Lift, the simply functional web framework http://liftweb.net
> Beginning Scala http://www.apress.com/book/view/1430219890
> Follow me: http://twitter.com/dpp
> Surf the harmonics
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to