Created
June 28, 2012 17:56
-
-
Save rktoomey/3012871 to your computer and use it in GitHub Desktop.
For Marcus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> import model._ | |
import model._ | |
scala> val afghanistan = JSONCountry("9c5bae60-4d6f-e111-afed-00155d6f0a00", "Afghanistan") | |
afghanistan: model.JSONCountry = JSONCountry(9c5bae60-4d6f-e111-afed-00155d6f0a00,Afghanistan) | |
scala> val j = JSONData(afghanistan :: Nil) | |
j: model.JSONData = JSONData(List(JSONCountry(9c5bae60-4d6f-e111-afed-00155d6f0a00,Afghanistan))) | |
scala> j.toJSON | |
res0: net.liftweb.json.package.JObject = JObject(List(JField(countries,JArray(List(JObject(List(JField(countryID,JString(9c5bae60-4d6f-e111-afed-00155d6f0a00)), JField(country,JString(Afghanistan))))))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package myApp | |
import com.novus.salat.{TypeHintFrequency, StringTypeHintStrategy, Context} | |
import com.novus.salat.json._ | |
import org.joda.time.format.ISODateTimeFormat | |
import org.joda.time.DateTimeZone | |
import com.novus.salat.StringTypeHintStrategy | |
package object context { | |
implicit val ctx = new Context { | |
val name = "json-test-context" | |
override val typeHintStrategy = StringTypeHintStrategy(when = TypeHintFrequency.WhenNecessary, | |
typeHint = "_t") | |
override val jsonConfig = JSONConfig( | |
dateStrategy = StringDateStrategy(dateFormatter = ISODateTimeFormat.dateTime.withZone(DateTimeZone.forID("US/Eastern"))), | |
objectIdStrategy = StringObjectIdStrategy) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package model | |
import myApp.context._ | |
import com.novus.salat._ | |
case class JSONData( | |
countries: List[JSONCountry]) { | |
def toJSON = grater[JSONData].toJSON(this) | |
} | |
case class JSONCountry( | |
countryID: String, | |
country: String) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment