0
私はScalaのGsonライブラリを使用しています。私のJSONは、私は次のコードScalaのGSon fromJsonが配列に失敗する
case class MyAdmin(id: String, userName: String, firstName: String, lastName: String, groups: List[String])
case class MyResponse(response: MyAdmin, count: Int)
に
val respScala = gson.fromJson(responseString, classOf[MyResponse])
のようなルックスを解析する私のコードを書かれているが、私はエラーに
Exception in thread "main" java.lang.RuntimeException: Failed to invoke public scala.collection.immutable.List() with no args
at com.google.gson.internal.ConstructorConstructor$3.construct(ConstructorConstructor.java:111)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:210)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220)
at com.google.gson.Gson.fromJson(Gson.java:887)
at com.google.gson.Gson.fromJson(Gson.java:852)
at com.google.gson.Gson.fromJson(Gson.java:801)
at com.google.gson.Gson.fromJson(Gson.java:773)
at com.researchnow.FlareCommandLine$.delayedEndpoint$com$researchnow$FlareCommandLine$1(FlareCommandLine.scala:28)
at com.researchnow.FlareCommandLine$delayedInit$body.apply(FlareCommandLine.scala:17)
at scala.Function0$class.apply$mcV$sp(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:381)
を取得し、これを解析するには
{"response":{"id":"xyz","userName":"foo","firstName":"foo","lastName":"bar","groups":["A", "B", "C"]}, "count":1}
のように見えます