Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Support for parameterized types #45

Open
aklossrbh opened this issue Feb 9, 2012 · 1 comment
Open

Support for parameterized types #45

aklossrbh opened this issue Feb 9, 2012 · 1 comment

Comments

@aklossrbh
Copy link

Jerkson can't deserialize into parameterized types. For example (based on ExampleCaseClasses.scala):

case class CaseClassWithList[T](id: Long, list: List[T])
parse[CaseClassWithList[CaseClass]]("""{"id":1,"list":[{"id":1,"name":"Coda"}]}""")

will throw a java.lang.ClassNotFoundException: T. Unlike issue #9, I'd like to be able to hint in the scala code (not in the JSON) that the parameterized type should be a CaseClass. I think something like parse[CaseClassWithList[CaseClass]](arg, List[Class]) where the list of classes would specify the parameterized types that ClassFileParser can't determine from the bytecode.

Thoughts? Is there a better way to do this? I made a commit in my fork of jerkson which has the full (failing) test case if that helps.

@ghost
Copy link

ghost commented Apr 1, 2012

I've recently encountered this limitation myself. What workaround have you found? I am pretty close to resorting to parsing into an Array[Any], re-generating the JSON string for each entry, then deserializing those strings. This doubles my parsing work, but will work around the problem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant