fork download
  1. def jsonFormat2[P1 :JF, P2 :JF, T <: Product :ClassManifest](construct: (P1, P2) => T): RootJsonFormat[T] = {
  2. val Array(p1, p2) = extractFieldNames(classManifest[T])
  3. jsonFormat(construct, p1, p2)
  4. }
  5.  
  6. def jsonFormat[P1 :JF, P2 :JF, T <: Product](construct: (P1, P2) => T, fieldName1: String, fieldName2: String): RootJsonFormat[T] = new RootJsonFormat[T]{
  7. def write(p: T) = {
  8. val fields = new collection.mutable.ListBuffer[(String, JsValue)]
  9. fields.sizeHint(2 * 2)
  10. fields ++= productElement2Field[P1](fieldName1, p, 0)
  11. fields ++= productElement2Field[P2](fieldName2, p, 1)
  12. JsObject(fields: _*)
  13. }
  14. def read(value: JsValue) = {
  15. val p1V = fromField[P1](value, fieldName1)
  16. val p2V = fromField[P2](value, fieldName2)
  17. construct(p1V, p2V)
  18. }
  19. }
  20.  
  21. trait Row extends IndexedSeq[Any] {
  22. def apply(columnNumber: Int ): Any
  23. def apply(columnName: String ): Any
  24. def rowNumber: Int
  25. }
  26.  
  27.  
  28. case class A(id: String = "A", data: String) extends O
  29.  
  30. object A {
  31. def apply(row: Row): A = {
  32. A(data = row(0).asInstanceOf[String])
  33. }
  34. }
  35.  
  36. object tERPJsonProtocol extends DefaultJsonProtocol {
  37. implicit val impA = jsonFormat2(A)
  38. }
  39.  
  40. object Main extends App {
  41. // your code goes here
  42. }
Compilation error #stdin compilation error #stdout 0.23s 381632KB
stdin
Standard input is empty
compilation info
/opt/scala/bin/scalac: line 50: /dev/null: Permission denied
Main.scala:1: error: expected class or object definition
def jsonFormat2[P1 :JF, P2 :JF, T <: Product :ClassManifest](construct: (P1, P2) => T): RootJsonFormat[T] = {
^
Main.scala:6: error: expected class or object definition
def jsonFormat[P1 :JF, P2 :JF, T <: Product](construct: (P1, P2) => T, fieldName1: String, fieldName2: String): RootJsonFormat[T] = new RootJsonFormat[T]{
^
two errors found
spoj: The program compiled successfully, but Main.class was not found.
      Class Main should contain method: def main(args: Array[String]).
stdout
Standard output is empty