diff options
author | Dan Brown <jdanbrown@gmail.com> | 2013-04-22 18:54:57 -0400 |
---|---|---|
committer | Dan Brown <jdanbrown@gmail.com> | 2013-04-22 19:07:21 -0400 |
commit | eacfb581fd89b0c9b3118e91e8b23db3b3ef0032 (patch) | |
tree | 760a89cefe5e5948dee19501b03335bcc3290828 /src/main/scala/spray | |
parent | 522c29d22a775ea7e6a8cd5fc2a50123bd94d66b (diff) | |
download | spray-json-eacfb581fd89b0c9b3118e91e8b23db3b3ef0032.tar.gz spray-json-eacfb581fd89b0c9b3118e91e8b23db3b3ef0032.tar.bz2 spray-json-eacfb581fd89b0c9b3118e91e8b23db3b3ef0032.zip |
Fix extractFieldNames: Ignore transient fields
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 5504fbd..fecc7de 100644 --- a/src/main/scala/spray/json/ProductFormats.scala +++ b/src/main/scala/spray/json/ProductFormats.scala @@ -16,6 +16,8 @@ package spray.json +import java.lang.reflect.Modifier + /** * Provides the helpers for constructing custom JsonFormat implementations for types implementing the Product trait * (especially case classes) @@ -499,7 +501,7 @@ trait ProductFormats { // 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(_.getName.startsWith("$")) + val fields = clazz.getDeclaredFields.filterNot(f => f.getName.startsWith("$") || Modifier.isTransient(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 }) |