Fix for issue with Lift-JSON occassionally choosing wrong constructor, resulting in erroneous serialization #3

wants to merge 3 commits into


None yet

2 participants

wfaler commented Feb 26, 2011

On decomposing a case class Lift-JSON will pick a constructor to base it's decomposition on with the "primaryConstructorArgs"-function, which previously picked the first available constructor.

However, the JVM does not guarantee the ordering of constructors, so in the case of classes with multiple alternative available constructors, the behavior becomes unpredictable and indeterminable.

I fixed this so that "primaryConstructorArgs" always picks the declared Constructor with the most arguments, as I felt this is a more reasonable assumption on the primary constructor for a case class to be serialized to JSON.

Let me know if this is acceptable, or if you want any changes.


love it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment