summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/scala/spray/json/JsonParser.scala4
-rw-r--r--src/test/scala/spray/json/JsonParserSpec.scala6
2 files changed, 9 insertions, 1 deletions
diff --git a/src/main/scala/spray/json/JsonParser.scala b/src/main/scala/spray/json/JsonParser.scala
index bed8dbd..855ab21 100644
--- a/src/main/scala/spray/json/JsonParser.scala
+++ b/src/main/scala/spray/json/JsonParser.scala
@@ -41,6 +41,7 @@ class JsonParser(input: ParserInput) {
def parseJsValue(): JsValue = {
ws()
`value`()
+ require(EOI)
jsValue
}
@@ -202,7 +203,8 @@ class JsonParser(input: ParserInput) {
val c = if (Character.isISOControl(errorChar)) "\\u%04x" format errorChar.toInt else errorChar.toString
s"character '$c'"
} else "end-of-input"
- s"Unexpected $unexpected at input index $cursor (line $lineNr, position $col), expected $target"
+ val expected = if (target != "'\uFFFF'") target else "end-of-input"
+ s"Unexpected $unexpected at input index $cursor (line $lineNr, position $col), expected $expected"
}
val detail = {
val sanitizedText = text.map(c ⇒ if (Character.isISOControl(c)) '?' else c)
diff --git a/src/test/scala/spray/json/JsonParserSpec.scala b/src/test/scala/spray/json/JsonParserSpec.scala
index 2fa089f..2bef24c 100644
--- a/src/test/scala/spray/json/JsonParserSpec.scala
+++ b/src/test/scala/spray/json/JsonParserSpec.scala
@@ -99,6 +99,12 @@ class JsonParserSpec extends Specification {
|{"a}
| ^
|""".stripMargin
+
+ errorMessage("""{}x""") ===
+ """Unexpected character 'x' at input index 2 (line 1, position 3), expected end-of-input:
+ |{}x
+ | ^
+ |""".stripMargin
}
}
} \ No newline at end of file