diff --git a/src/main/scala/com/codahale/jerkson/Parser.scala b/src/main/scala/com/codahale/jerkson/Parser.scala index e63c077..0c53192 100644 --- a/src/main/scala/com/codahale/jerkson/Parser.scala +++ b/src/main/scala/com/codahale/jerkson/Parser.scala @@ -12,43 +12,36 @@ trait Parser extends Factory { * Parse a JSON string as a particular type. */ def parse[A](input: String)(implicit mf: Manifest[A]): A = parse[A](factory.createJsonParser(input), mf) - def parse[A](input: String, klass: Class[A]): A = parse[A](input)(Manifest.classType(klass)) /** * Parse a JSON input stream as a particular type. */ def parse[A](input: InputStream)(implicit mf: Manifest[A]): A = parse[A](factory.createJsonParser(input), mf) - def parse[A](input: InputStream, klass: Class[A]): A = parse[A](input)(Manifest.classType(klass)) /** * Parse a JSON file as a particular type. */ def parse[A](input: File)(implicit mf: Manifest[A]): A = parse[A](factory.createJsonParser(input), mf) - def parse[A](input: File, klass: Class[A]): A = parse[A](input)(Manifest.classType(klass)) /** * Parse a JSON URL as a particular type. */ def parse[A](input: URL)(implicit mf: Manifest[A]): A = parse[A](factory.createJsonParser(input), mf) - def parse[A](input: URL, klass: Class[A]): A = parse[A](input)(Manifest.classType(klass)) /** * Parse a JSON Reader as a particular type. */ def parse[A](input: Reader)(implicit mf: Manifest[A]): A = parse[A](factory.createJsonParser(input), mf) - def parse[A](input: Reader, klass: Class[A]): A = parse[A](input)(Manifest.classType(klass)) /** * Parse a JSON byte array as a particular type. */ def parse[A](input: Array[Byte])(implicit mf: Manifest[A]): A = parse[A](factory.createJsonParser(input), mf) - def parse[A](input: Array[Byte], klass: Class[A]): A = parse[A](input)(Manifest.classType(klass)) /** * Parse a JSON Source as a particular type. */ def parse[A](input: Source)(implicit mf: Manifest[A]): A = parse[A](input.mkString) - def parse[A](input: Source, klass: Class[A]): A = parse[A](input)(Manifest.classType(klass)) /** * Parse a JSON node as a particular type. @@ -57,7 +50,6 @@ trait Parser extends Factory { val parser = new TreeTraversingParser(input, mapper) parse(parser, mf) } - def parse[A](input: JsonNode, klass: Class[A]): A = parse[A](input)(Manifest.classType(klass)) /** * Parse a streaming JSON array of particular types, returning an iterator @@ -67,7 +59,6 @@ trait Parser extends Factory { val parser = factory.createJsonParser(input) new StreamingIterator[A](parser, mf) } - def stream[A](input: InputStream, klass: Class[A]): Iterator[A] = stream[A](input)(Manifest.classType(klass)) /** * Parse a streaming JSON array of particular types, returning an iterator @@ -77,7 +68,6 @@ trait Parser extends Factory { val parser = factory.createJsonParser(input) new StreamingIterator[A](parser, mf) } - def stream[A](input: Reader, klass: Class[A]): Iterator[A] = stream[A](input)(Manifest.classType(klass)) private[jerkson] def parse[A](parser: JsonParser, mf: Manifest[A]): A = { try { diff --git a/src/test/scala/com/codahale/jerkson/tests/EdgeCaseSpec.scala b/src/test/scala/com/codahale/jerkson/tests/EdgeCaseSpec.scala index 9ae2a0a..4fdcb1c 100644 --- a/src/test/scala/com/codahale/jerkson/tests/EdgeCaseSpec.scala +++ b/src/test/scala/com/codahale/jerkson/tests/EdgeCaseSpec.scala @@ -28,7 +28,7 @@ class EdgeCaseSpec extends Spec { } class `Parsing malformed JSON` { - @Test def `throws a ParsingException with an informative message` = { + @Test def `should throw a ParsingException with an informative message` = { evaluating { parse[Boolean]("jjf8;09") }.must(throwA[ParsingException]( @@ -45,7 +45,7 @@ class EdgeCaseSpec extends Spec { } class `Parsing invalid JSON` { - @Test def `throws a ParsingException with an informative message` = { + @Test def `should throw a ParsingException with an informative message` = { evaluating { parse[CaseClass]("900") }.must(throwA[ParsingException]( @@ -59,17 +59,11 @@ class EdgeCaseSpec extends Spec { } class `Parsing an empty document` { - @Test def `throws a ParsingException with an informative message` = { + @Test def `should throw a ParsingException with an informative message` = { val input = new ByteArrayInputStream(Array.empty) evaluating { parse[CaseClass](input) }.must(throwA[ParsingException]("JSON document ended unexpectedly.")) } } - - class `Parsing a document with a Class[A]` { - @Test def `works` = { - parse("\"womp\"", classOf[String]).must(be("womp")) - } - } }