Skip to content

Commit

Permalink
Fix a bug in deserializing empty JSON objects as JValues.
Browse files Browse the repository at this point in the history
  • Loading branch information
codahale committed Jun 15, 2011
1 parent 457ec62 commit 6fb62ff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Expand Up @@ -27,7 +27,7 @@ class JValueDeserializer(klass: Class[_]) extends JsonDeserializer[Object] {
jp.nextToken()
deserialize(jp, ctxt)
}
case JsonToken.FIELD_NAME => {
case JsonToken.FIELD_NAME | JsonToken.END_OBJECT => {
val fields = new ArrayBuffer[JField]
while (jp.getCurrentToken != JsonToken.END_OBJECT) {
val name = jp.getCurrentName
Expand Down
Expand Up @@ -116,5 +116,9 @@ class ASTTypeSupportSpec extends Spec {
def `is parsable from a JSON object as a JValue` = {
parse[JValue]("""{"id":1,"name":"Coda"}""") must beEqualTo(obj)
}

def `is parsable from an empty JSON object` = {
parse[JObject]("""{}""") must beEqualTo(JObject(Nil))
}
}
}

0 comments on commit 6fb62ff

Please sign in to comment.