diff options
author | Mark van der Tol <github@markvandertol.nl> | 2013-10-13 18:02:49 +0200 |
---|---|---|
committer | Mark van der Tol <github@markvandertol.nl> | 2013-10-13 18:02:49 +0200 |
commit | b1bd64e5ec75665aff9fe8f3915dac23e737498f (patch) | |
tree | 062a7334f11480aadf4d01bdb73840866080708d /src/main/scala/spray | |
parent | 4be4d6ff8e466b52fbb349a823549424e2e259eb (diff) | |
download | spray-json-b1bd64e5ec75665aff9fe8f3915dac23e737498f.tar.gz spray-json-b1bd64e5ec75665aff9fe8f3915dac23e737498f.tar.bz2 spray-json-b1bd64e5ec75665aff9fe8f3915dac23e737498f.zip |
Ignore static fields in jsonFormat
Diffstat (limited to 'src/main/scala/spray')
-rw-r--r-- | src/main/scala/spray/json/ProductFormats.scala | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/main/scala/spray/json/ProductFormats.scala b/src/main/scala/spray/json/ProductFormats.scala index 8b5843f..ad57221 100644 --- a/src/main/scala/spray/json/ProductFormats.scala +++ b/src/main/scala/spray/json/ProductFormats.scala @@ -61,7 +61,9 @@ trait ProductFormats extends ProductFormatsInstances { // that lexical sorting of ...8(), ...9(), ...10() is not correct, so we extract N and sort by N.toInt val copyDefaultMethods = clazz.getMethods.filter(_.getName.startsWith("copy$default$")).sortBy( _.getName.drop("copy$default$".length).takeWhile(_ != '(').toInt) - val fields = clazz.getDeclaredFields.filterNot(f => f.getName.startsWith("$") || Modifier.isTransient(f.getModifiers)) + val fields = clazz.getDeclaredFields.filterNot { f => + f.getName.startsWith("$") || Modifier.isTransient(f.getModifiers) || Modifier.isStatic(f.getModifiers) + } if (copyDefaultMethods.length != fields.length) sys.error("Case class " + clazz.getName + " declares additional fields") if (fields.zip(copyDefaultMethods).exists { case (f, m) => f.getType != m.getReturnType }) |