import net.liftweb.json.DefaultFormats import net.liftweb.json.Serialization._ object PersonScript { case class Person(name: String) val createPerson = http("Create person") .post("/person") .body(StringBody(session => write(Person("Jack"))(DefaultFormats))).asJSON }
The Person case class represents the JSON body structure you want to post.
The StringBody code line converts the case object into JSON representation for post.
Ensure to have following dependency in your classpath.
<dependency> <groupId>net.liftweb</groupId> <artifactId>lift-json_2.11</artifactId> <version>3.0-M7</version> </dependency>
No comments:
Post a Comment