Skip to content

Commit

Permalink
correctly parse empty strings
Browse files Browse the repository at this point in the history
  • Loading branch information
freels committed Sep 2, 2010
1 parent 18f3079 commit e0b55b6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
project.organization=com.twitter
project.name=json
sbt.version=0.7.4
project.version=1.1.5
project.version=1.1.6
def.scala.version=2.7.7
build.scala.versions=2.7.7
project.initialize=false
2 changes: 1 addition & 1 deletion src/main/scala/com/twitter/json/Json.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private class JsonParser extends JavaTokenParsers {
lazy val stringParser = (new EscapedStringParser)

def string: Parser[String] =
"\"" ~> """(\\"|[^"])+""".r <~ "\"" ^^ { escapedStr =>
"\"" ~> """(\\"|[^"])*""".r <~ "\"" ^^ { escapedStr =>
stringParser.parse(escapedStr)
}

Expand Down
4 changes: 4 additions & 0 deletions src/test/scala/com/twitter/json/JsonSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ object JsonSpec extends Specification {
List("hi\njerk")
}

"empty string" in {
Json.parse("""[""]""") mustEqual List("")
}

"quoted quote" in {
Json.parse("""["x\"x"]""") mustEqual
List("x\"x")
Expand Down

0 comments on commit e0b55b6

Please sign in to comment.