Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use NameTransformer to unmangle symbolic names, fixes 1075

  • Loading branch information...
commit 1c9629e94fe8e2a6158414670f0b68f4726901db 1 parent f24ceaa
Joni Freeman authored
View
8 core/json/src/main/scala/net/liftweb/json/Meta.scala
@@ -184,16 +184,10 @@ private[json] object Meta {
}
private[json] def unmangleName(name: String) =
- unmangledNames.memoize(name, operators.foldLeft(_)((n, o) => n.replace(o._1, o._2)))
+ unmangledNames.memoize(name, scala.reflect.NameTransformer.decode)
private[json] def fail(msg: String, cause: Exception = null) = throw new MappingException(msg, cause)
- private val operators = Map(
- "$eq" -> "=", "$greater" -> ">", "$less" -> "<", "$plus" -> "+", "$minus" -> "-",
- "$times" -> "*", "$div" -> "/", "$bang" -> "!", "$at" -> "@", "$hash" -> "#",
- "$percent" -> "%", "$up" -> "^", "$amp" -> "&", "$tilde" -> "~", "$qmark" -> "?",
- "$bar" -> "|", "$bslash" -> "\\")
-
private class Memo[A, R] {
private var cache = Map[A, R]()
View
10 core/json/src/test/scala/net/liftweb/json/ExtractionBugs.scala
@@ -19,10 +19,6 @@ package json
import org.specs.Specification
-
-/**
- * System under specification for Extraction bugs.
- */
object ExtractionBugs extends Specification("Extraction bugs Specification") {
implicit val formats = DefaultFormats
@@ -48,6 +44,10 @@ object ExtractionBugs extends Specification("Extraction bugs Specification") {
extracted mustEqual ExtractWithAnyRef()
}
+ "Extraction should work with unicode encoded field names (issue 1075)" in {
+ parse("""{"foo.bar,baz":"x"}""").extract[UnicodeFieldNames] mustEqual UnicodeFieldNames("x")
+ }
+
case class OptionOfInt(opt: Option[Int])
case class PMap(m: Map[String, List[String]])
@@ -59,4 +59,6 @@ object ExtractionBugs extends Specification("Extraction bugs Specification") {
}
case class ExtractWithAnyRef()
+
+ case class UnicodeFieldNames(`foo.bar,baz`: String)
}
View
4 core/json/src/test/scala/net/liftweb/json/ExtractionExamplesSpec.scala
@@ -20,10 +20,6 @@ package json
import java.util.Date
import org.specs.Specification
-
-/**
- * Systems under specification for Extraction Examples.
- */
object ExtractionExamples extends Specification("Extraction Examples Specification") {
implicit val formats = DefaultFormats
Please sign in to comment.
Something went wrong with that request. Please try again.