Niels Boldt <nielsbo...@gmail.com> writes:

> Hi,
>
> What is the best way to create a rest service in lift that support both xml
> and json.
>
> Are there any tools to use besides lift-json. The end result of my service
> call will be a pojo object that is grabbed from a database and should be
> transformed to the appropriate output.
>
> I hoped to do that in a generic way, whether it is xml, json or something
> third

Not sure what your main problem (REST api part or obj->response) is but:

The API part goes something like this:

LiftRules.dispatch.append {
  case Req("api" :: "thing" :: Nil, "json", GetRequest) => // function that 
returns a Box[LiftResponse]
}

so you can create different functions based on the request suffix (ie
json/xml) and return appropriate responses.

The Lift ORM, Mapper, recently got an "asJSON" method to return contents of
an object as JSON (it uses lift-json).

I'm not aware of any Scala/Lift generic XML serialization stuff, but you
can use any Java lib for this. For one-off XML structures, it's very
simple to create the XML inline in Scala....

/Jeppe

--

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