Note that there are some explanatory texts on larger screens.

plurals
  1. POParsing an array of json objects to scala objects with pickling
    primarykey
    data
    text
    <p>I'm trying to convert an array of JSON objects from a key to an array of objects in Scala...</p> <p>Here is the code:</p> <pre><code>case class RoomList(val rooms : Array[Room]) case class Room(val name : String) val json = "{\"rooms\" : [{\"name\" : \"Test\"}]}" println(json.unpickle[RoomList]) </code></pre> <p>Here is the exception</p> <pre><code>Exception in thread "main" java.lang.InstantiationException: [Lhipchat.Room; at sun.misc.Unsafe.allocateInstance(Native Method) at hipchat.HipChat$HipchatRoomListUnpickler1$2$ScalaArray$u005BhipchatRoom$u005DUnpickler1$2$.unpickle(HipChat.scala:46) at hipchat.HipChat$HipchatRoomListUnpickler1$2$.unpickle(HipChat.scala:46) at hipchat.HipChat.getRooms(HipChat.scala:46) at bot.Bot$.main(Bot.scala:11) at bot.Bot.main(Bot.scala) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) </code></pre> <p>Here is a RoomList:</p> <pre><code>val room = new Room("test") val rooms = Array(room) val rl = new RoomList(rooms) println(rl.pickle) </code></pre> <p>Pickled:</p> <pre><code>JSONPickle({ "tpe": "hipchat.RoomList", "rooms": { } }) </code></pre> <p>And a pickled Room:</p> <pre><code>JSONPickle({ "tpe": "hipchat.Room", "name": "test" }) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload