Permalink
Browse files

Rename jfc to circe

  • Loading branch information...
travisbrown committed Aug 9, 2015
1 parent 764afc2 commit 4c1fb728e4d600e2e95692901eb4bed462af1e3a
Showing with 211 additions and 212 deletions.
  1. +1 −1 NOTICE
  2. +40 −40 README.md
  3. +3 −3 async/src/main/scala/io/{jfc → circe}/async/StreamingParser.scala
  4. +22 −22 benchmark/src/main/scala/io/{jfc → circe}/benchmark/Benchmark.scala
  5. +16 −17 build.sbt
  6. +2 −2 core/src/main/scala/io/{jfc → circe}/ACursor.scala
  7. +1 −1 core/src/main/scala/io/{jfc → circe}/Context.scala
  8. +2 −2 core/src/main/scala/io/{jfc → circe}/Cursor.scala
  9. +1 −1 core/src/main/scala/io/{jfc → circe}/CursorOp.scala
  10. +1 −1 core/src/main/scala/io/{jfc → circe}/CursorOpElement.scala
  11. +2 −2 core/src/main/scala/io/{jfc → circe}/Decoder.scala
  12. +2 −2 core/src/main/scala/io/{jfc → circe}/Encoder.scala
  13. +1 −1 core/src/main/scala/io/{jfc → circe}/Error.scala
  14. +2 −2 core/src/main/scala/io/{jfc → circe}/GenericCursor.scala
  15. +2 −2 core/src/main/scala/io/{jfc → circe}/HCursor.scala
  16. +7 −7 core/src/main/scala/io/{jfc → circe}/Json.scala
  17. +5 −5 core/src/main/scala/io/{jfc → circe}/JsonNumber.scala
  18. +1 −1 core/src/main/scala/io/{jfc → circe}/JsonObject.scala
  19. +1 −1 core/src/main/scala/io/{jfc → circe}/ObjectEncoder.scala
  20. +1 −1 core/src/main/scala/io/{jfc → circe}/Parser.scala
  21. +5 −5 core/src/main/scala/io/{jfc → circe}/Printer.scala
  22. +1 −0 core/src/main/scala/io/circe/Result.scala
  23. +4 −4 core/src/main/scala/io/{jfc → circe}/cursor/ACursorOperations.scala
  24. +3 −3 core/src/main/scala/io/{jfc → circe}/cursor/CArray.scala
  25. +3 −3 core/src/main/scala/io/{jfc → circe}/cursor/CJson.scala
  26. +3 −3 core/src/main/scala/io/{jfc → circe}/cursor/CObject.scala
  27. +4 −4 core/src/main/scala/io/{jfc → circe}/cursor/CursorOperations.scala
  28. +5 −5 core/src/main/scala/io/{jfc → circe}/cursor/HCursorOperations.scala
  29. +1 −1 core/src/main/scala/io/{jfc → circe}/disjunctionCodecs.scala
  30. +3 −0 core/src/main/scala/io/circe/package.scala
  31. +1 −1 core/src/main/scala/io/{jfc → circe}/syntax/package.scala
  32. +0 −1 core/src/main/scala/io/jfc/Result.scala
  33. +0 −3 core/src/main/scala/io/jfc/package.scala
  34. +2 −2 core/src/test/scala/io/{jfc → circe}/CodecTests.scala
  35. +2 −2 core/src/test/scala/io/{jfc → circe}/CursorTests.scala
  36. +2 −2 core/src/test/scala/io/{jfc → circe}/JsonNumberTests.scala
  37. +3 −3 core/src/test/scala/io/{jfc → circe}/SyntaxTests.scala
  38. +2 −2 core/src/test/scala/io/{jfc → circe}/test/ArbitraryInstances.scala
  39. +2 −2 core/src/test/scala/io/{jfc → circe}/test/CodecTests.scala
  40. +3 −3 core/src/test/scala/io/{jfc → circe}/test/CursorSuite.scala
  41. +1 −1 core/src/test/scala/io/{jfc → circe}/test/JfcSuite.scala
  42. +1 −1 core/src/test/scala/io/{jfc → circe}/test/MissingInstances.scala
  43. +2 −2 core/src/test/scala/io/{jfc → circe}/test/ParserTests.scala
  44. +2 −2 generic/src/main/scala/io/{jfc → circe}/generic/BaseInstances.scala
  45. +1 −1 generic/src/main/scala/io/{jfc → circe}/generic/Complement.scala
  46. +2 −2 generic/src/main/scala/io/{jfc → circe}/generic/GenericInstances.scala
  47. +2 −2 generic/src/main/scala/io/{jfc → circe}/generic/HListInstances.scala
  48. +2 −2 generic/src/main/scala/io/{jfc → circe}/generic/IncompleteInstances.scala
  49. +2 −2 generic/src/main/scala/io/{jfc → circe}/generic/LabelledInstances.scala
  50. +2 −2 generic/src/main/scala/io/{jfc → circe}/generic/ProductDecoder.scala
  51. +2 −2 generic/src/main/scala/io/{jfc → circe}/generic/ProductEncoder.scala
  52. +2 −2 generic/src/main/scala/io/{jfc → circe}/generic/TupleInstances.scala
  53. +2 −2 generic/src/main/scala/io/{jfc → circe}/generic/auto.scala
  54. +4 −4 generic/src/main/scala/io/{jfc → circe}/generic/semiauto.scala
  55. +2 −2 generic/src/test/scala/io/{jfc → circe}/generic/ComplementTests.scala
  56. +2 −2 generic/src/test/scala/io/{jfc → circe}/generic/Examples.scala
  57. +4 −4 generic/src/test/scala/io/{jfc → circe}/generic/SemiautoCodecTests.scala
  58. +4 −4 generic/src/test/scala/io/{jfc → circe}/generic/auto/AutoCodecTests.scala
  59. +2 −2 jawn/src/main/scala/io/{jfc → circe}/jawn/JawnParser.scala
  60. +2 −2 jawn/src/main/scala/io/{jfc → circe}/jawn/JfcSupportParser.scala
  61. +1 −1 jawn/src/main/scala/io/{jfc → circe}/jawn/package.scala
  62. 0 jawn/src/test/resources/io/{jfc → circe}/glossary.json
  63. +5 −5 jawn/src/test/scala/io/{jfc → circe}/jawn/JawnParserTests.scala
View
2 NOTICE
@@ -1,4 +1,4 @@
jfc
circe
Copyright (c) 2015, Ephox Pty Ltd, Mark Hibberd, Sean Parsons, Travis Brown, and
other contributors. All rights reserved.
View
@@ -1,26 +1,26 @@
# jfc
# circe
[![Build status](https://img.shields.io/travis/travisbrown/jfc/master.svg)](https://travis-ci.org/travisbrown/jfc)
[![Coverage status](https://img.shields.io/codecov/c/github/travisbrown/jfc/master.svg)](https://codecov.io/github/travisbrown/jfc)
[![Gitter](https://img.shields.io/badge/gitter-join%20chat-green.svg)](https://gitter.im/travisbrown/jfc)
[![Build status](https://img.shields.io/travis/travisbrown/circe/master.svg)](https://travis-ci.org/travisbrown/circe)
[![Coverage status](https://img.shields.io/codecov/c/github/travisbrown/circe/master.svg)](https://codecov.io/github/travisbrown/circe)
[![Gitter](https://img.shields.io/badge/gitter-join%20chat-green.svg)](https://gitter.im/travisbrown/circe)
jfc is a JSON library for Scala. The rest of this page tries to give some justification for its
circe is a JSON library for Scala. The rest of this page tries to give some justification for its
existence. There are also [API docs][api].
The name stands for "JSON for [cats][cats]" and is a working title that
[is being changed](https://github.com/travisbrown/jfc/issues/11).
circe's working title was jfc, which stood for "JSON for [cats][cats]". The name was changed for [a
number of reasons](https://github.com/travisbrown/circe/issues/11).
## Showing off
Type `sbt console` to start a REPL in the root project, and then paste the following:
```scala
scala> import io.jfc._, io.jfc.generic.auto._, io.jfc.jawn._, io.jfc.syntax._
import io.jfc._
import io.jfc.auto._
import io.jfc.jawn._
import io.jfc.syntax._
scala> import io.circe._, io.circe.generic.auto._, io.circe.jawn._, io.circe.syntax._
import io.circe._
import io.circe.auto._
import io.circe.jawn._
import io.circe.syntax._
scala> sealed trait Foo
defined trait Foo
@@ -38,7 +38,7 @@ scala> foo.asJson.noSpaces
res0: String = {"Qux":{"d":14.0,"i":13}}
scala> decode[Foo](foo.asJson.spaces4)
res1: cats.data.Xor[io.jfc.Error,Foo] = Right(Qux(13,Some(14.0)))
res1: cats.data.Xor[io.circe.Error,Foo] = Right(Qux(13,Some(14.0)))
```
No boilerplate, no runtime reflection.
@@ -48,55 +48,55 @@ No boilerplate, no runtime reflection.
[Argonaut][argonaut] is a great library. It's by far the best JSON library for Scala, and the best
JSON library on the JVM. If you're doing anything with JSON in Scala, you should be using Argonaut.
jfc is a fork of Argonaut with a few important differences.
circe is a fork of Argonaut with a few important differences.
### Dependencies and modularity
jfc depends on [cats][cats] instead of [Scalaz][scalaz], and cats is the only dependency of the
circe depends on [cats][cats] instead of [Scalaz][scalaz], and cats is the only dependency of the
`core` project.
Other subprojects bring in dependencies on [Jawn][jawn] (for parsing in the [`jawn`][jfc-jawn]
subproject), [Shapeless][shapeless] (for automatic codec derivation in [`generic`][jfc-generic]),
Other subprojects bring in dependencies on [Jawn][jawn] (for parsing in the [`jawn`][circe-jawn]
subproject), [Shapeless][shapeless] (for automatic codec derivation in [`generic`][circe-generic]),
and [Twitter Util][util] (for tools for asynchronous parsing in `async`), but it would be possible
to replace the functionality provided by these subprojects with alternative implementations that use
other libraries.
### Parsing
jfc doesn't include a JSON parser in the `core` project, which is focused on the JSON AST, zippers,
and codecs. The [`jawn`][jfc-jawn] subproject provides support for parsing JSON via a [Jawn][jawn]
circe doesn't include a JSON parser in the `core` project, which is focused on the JSON AST, zippers,
and codecs. The [`jawn`][circe-jawn] subproject provides support for parsing JSON via a [Jawn][jawn]
facade. Jawn is fast, it offers asynchronous parsing, and best of all it lets us drop a lot of the
fussiest code in Argonaut.
### Lenses
jfc doesn't use or provide lenses in the `core` project (or at all, for now). This is related to
circe doesn't use or provide lenses in the `core` project (or at all, for now). This is related to
the first point above, since [Monocle][monocle] has a Scalaz dependency, but we also feel that it
simplifies the API. We'd consider adding lenses in a subproject if Monocle (or something similar)
gets ported to cats.
### Codec derivation
jfc does not use macros or provide any kind of automatic derivation in the `core` project. Instead
circe does not use macros or provide any kind of automatic derivation in the `core` project. Instead
of Argonaut's limited macro-based derivation (which does not support sealed trait hierarchies, for
example), jfc includes a subproject (`generic`) that provides generic codec derivation using
example), circe includes a subproject (`generic`) that provides generic codec derivation using
[Shapeless][shapeless].
[This subproject][jfc-generic] is currently a simplified port of
[This subproject][circe-generic] is currently a simplified port of
[argonaut-shapeless][argonaut-shapeless] that provides fully automatic derivation of instances for
tuples, case classes, and sealed trait hierarchies. It also includes derivation of "incomplete" case
classes (see my recent [blog post][incompletes] for details).
### Aliases
jfc aims to simplify Argonaut's API by removing all operator aliases. This is largely a matter of
circe aims to simplify Argonaut's API by removing all operator aliases. This is largely a matter of
personal taste, and may change in the future.
### Documentation
The Argonaut documentation is good, but it could be better: to take just one example, it can be hard
to tell at a glance why there are three different `Cursor`, `HCursor`, and `ACursor` types. In this
particular case, jfc introduces an abstraction over cursors that makes the relationship clearer and
particular case, circe introduces an abstraction over cursors that makes the relationship clearer and
allows these three types to [share API documentation][generic-cursor].
### Testing
@@ -106,9 +106,9 @@ early days for this.
### Performance
jfc aims to be more focused on performance. I'm still experimenting with the right balance, but I'm
circe aims to be more focused on performance. I'm still experimenting with the right balance, but I'm
open to using mutability, inheritance, and all kinds of other horrible things under the hood if they
make jfc faster (the public API does not and will never expose any of this, though).
make circe faster (the public API does not and will never expose any of this, though).
[My initial benchmarks][benchmarks] suggest this is at least kind of working (higher numbers are
better):
@@ -172,17 +172,17 @@ PrintingBenchmark.printIntsJ:gc.alloc.rate.norm 20 95408.077 ± 0.149
```
The `Foos` benchmarks work with a map containing case class values, and the `Ints` ones are an array
of integers. `J` suffixes indicate jfc's throughput and `A` is for Argonaut.
of integers. `J` suffixes indicate circe's throughput and `A` is for Argonaut.
## Usage
This section needs a lot of expanding.
### Encoding and decoding
jfc uses `Encoder` and `Decoder` type classes for encoding and decoding. An `Encoder[A]` instance
circe uses `Encoder` and `Decoder` type classes for encoding and decoding. An `Encoder[A]` instance
provides a function that will convert any `A` to a `JSON`, and a `Decoder[A]` takes a `Json` value
to either an exception or an `A`. jfc provides implicit instances of these type classes for many
to either an exception or an `A`. circe provides implicit instances of these type classes for many
types from the Scala standard library, including `Int`, `String`, and [others][encoder]. It also
provides instances for `List[A]`, `Option[A]`, and other generic types, but only if `A` has an
`Encoder` instance.
@@ -192,7 +192,7 @@ provides instances for `List[A]`, `Option[A]`, and other generic types, but only
Suppose we have the following JSON document:
```scala
import io.jfc._, io.jfc.generic.auto._, io.jfc.jawn._, io.jfc.syntax._
import io.circe._, io.circe.generic.auto._, io.circe.jawn._, io.circe.syntax._
import cats.data.Xor
val json: String = """
@@ -236,15 +236,15 @@ The result will contain the original document with the `"name"` field reversed.
## Contributors
jfc is a fork of Argonaut, and if you find it at all useful, you should thank
circe is a fork of Argonaut, and if you find it at all useful, you should thank
[Mark Hibberd][markhibberd], [Tony Morris][tonymorris], [Kenji Yoshida][xuwei-k], and the rest of
the [Argonaut contributors][argonaut-contributors].
jfc is currently developed and maintained by [Travis Brown][travisbrown].
circe is currently developed and maintained by [Travis Brown][travisbrown].
## License
jfc is licensed under the **[Apache License, Version 2.0][apache]** (the
circe is licensed under the **[Apache License, Version 2.0][apache]** (the
"License"); you may not use this software except in compliance with the License.
Unless required by applicable law or agreed to in writing, software
@@ -254,20 +254,20 @@ See the License for the specific language governing permissions and
limitations under the License.
[apache]: http://www.apache.org/licenses/LICENSE-2.0
[api]: https://travisbrown.github.io/circe/api/#io.jfc.package
[api]: https://travisbrown.github.io/circe/api/#io.circe.package
[argonaut]: http://argonaut.io/
[argonaut-contributors]: https://github.com/argonaut-io/argonaut/graphs/contributors
[argonaut-shapeless]: https://github.com/alexarchambault/argonaut-shapeless
[benchmarks]: https://github.com/travisbrown/circe/blob/topic/plugins/benchmark/src/main/scala/io/jfc/benchmark/Benchmark.scala
[benchmarks]: https://github.com/travisbrown/circe/blob/topic/plugins/benchmark/src/main/scala/io/circe/benchmark/Benchmark.scala
[cats]: https://github.com/non/cats
[discipline]: https://github.com/typelevel/discipline
[encoder]: https://travisbrown.github.io/circe/api/#io.jfc.Encoder$
[encoder]: https://travisbrown.github.io/circe/api/#io.circe.Encoder$
[finch]: https://github.com/finagle/finch
[generic-cursor]: https://travisbrown.github.io/circe/api/#io.jfc.GenericCursor
[generic-cursor]: https://travisbrown.github.io/circe/api/#io.circe.GenericCursor
[incompletes]: https://meta.plasm.us/posts/2015/06/21/deriving-incomplete-type-class-instances/
[jawn]: https://github.com/non/jawn
[jfc-generic]: https://travisbrown.github.io/circe/api/#io.jfc.generic.auto$
[jfc-jawn]: https://travisbrown.github.io/circe/api/#io.jfc.jawn.package
[circe-generic]: https://travisbrown.github.io/circe/api/#io.circe.generic.auto$
[circe-jawn]: https://travisbrown.github.io/circe/api/#io.circe.jawn.package
[markhibberd]: https://github.com/markhibberd
[monocle]: https://github.com/julien-truffaut/Monocle
[scalaz]: https://github.com/scalaz/scalaz
@@ -1,10 +1,10 @@
package io.jfc.async
package io.circe.async
import com.twitter.concurrent.{ Spool, SpoolSource }
import com.twitter.io.Buf
import com.twitter.util.Future
import io.jfc.Json
import io.jfc.jawn.JfcSupportParser
import io.circe.Json
import io.circe.jawn.JfcSupportParser
import jawn.AsyncParser
/**
@@ -1,9 +1,9 @@
package io.jfc.benchmark
package io.circe.benchmark
import argonaut.{ Json => JsonA, _ }, Argonaut._
import io.jfc.{ Json => JsonJ, Encoder }
import io.jfc.generic.auto._
import io.jfc.jawn._
import io.circe.{ Json => JsonC, Encoder }
import io.circe.generic.auto._
import io.circe.jawn._
import java.util.concurrent.TimeUnit
import org.openjdk.jmh.annotations._
@@ -21,38 +21,38 @@ class ExampleData {
}.toMap
@inline def encodeA[A](a: A)(implicit encode: EncodeJson[A]): JsonA = encode(a)
@inline def encodeJ[A](a: A)(implicit encode: Encoder[A]): JsonJ = encode(a)
@inline def encodeC[A](a: A)(implicit encode: Encoder[A]): JsonC = encode(a)
val intsJ: JsonJ = encodeJ(ints)
val intsC: JsonC = encodeC(ints)
val intsA: JsonA = encodeA(ints)
val foosJ: JsonJ = encodeJ(foos)
val foosC: JsonC = encodeC(foos)
val foosA: JsonA = encodeA(foos)
val intsJson: String = intsJ.noSpaces
val foosJson: String = foosJ.noSpaces
val intsJson: String = intsC.noSpaces
val foosJson: String = foosC.noSpaces
}
/**
* Compare the performance of encoding operations.
*
* The following command will run the benchmarks with reasonable settings:
*
* > sbt "benchmark/run -i 10 -wi 10 -f 2 -t 1 io.jfc.benchmark.EncodingBenchmark"
* > sbt "benchmark/run -i 10 -wi 10 -f 2 -t 1 io.circe.benchmark.EncodingBenchmark"
*/
@State(Scope.Thread)
@BenchmarkMode(Array(Mode.Throughput))
@OutputTimeUnit(TimeUnit.SECONDS)
class EncodingBenchmark extends ExampleData {
@Benchmark
def encodeIntsJ: JsonJ = encodeJ(ints)
def encodeIntsC: JsonC = encodeC(ints)
@Benchmark
def encodeIntsA: JsonA = encodeA(ints)
@Benchmark
def encodeFoosJ: JsonJ = encodeJ(foos)
def encodeFoosC: JsonC = encodeC(foos)
@Benchmark
def encodeFoosA: JsonA = encodeA(foos)
@@ -63,21 +63,21 @@ class EncodingBenchmark extends ExampleData {
*
* The following command will run the benchmarks with reasonable settings:
*
* > sbt "benchmark/run -i 10 -wi 10 -f 2 -t 1 io.jfc.benchmark.DecodingBenchmark"
* > sbt "benchmark/run -i 10 -wi 10 -f 2 -t 1 io.circe.benchmark.DecodingBenchmark"
*/
@State(Scope.Thread)
@BenchmarkMode(Array(Mode.Throughput))
@OutputTimeUnit(TimeUnit.SECONDS)
class DecodingBenchmark extends ExampleData {
@Benchmark
def decodeIntsJ: List[Int] = intsJ.as[List[Int]].getOrElse(throw new Exception)
def decodeIntsC: List[Int] = intsC.as[List[Int]].getOrElse(throw new Exception)
@Benchmark
def decodeIntsA: List[Int] = intsA.as[List[Int]].result.getOrElse(throw new Exception)
@Benchmark
def decodeFoosJ: Map[String, Foo] =
foosJ.as[Map[String, Foo]].getOrElse(throw new Exception)
def decodeFoosC: Map[String, Foo] =
foosC.as[Map[String, Foo]].getOrElse(throw new Exception)
@Benchmark
def decodeFoosA: Map[String, Foo] =
@@ -89,20 +89,20 @@ class DecodingBenchmark extends ExampleData {
*
* The following command will run the benchmarks with reasonable settings:
*
* > sbt "benchmark/run -i 10 -wi 10 -f 2 -t 1 io.jfc.benchmark.ParsingBenchmark"
* > sbt "benchmark/run -i 10 -wi 10 -f 2 -t 1 io.circe.benchmark.ParsingBenchmark"
*/
@State(Scope.Thread)
@BenchmarkMode(Array(Mode.Throughput))
@OutputTimeUnit(TimeUnit.SECONDS)
class ParsingBenchmark extends ExampleData {
@Benchmark
def parseIntsJ: JsonJ = parse(intsJson).getOrElse(throw new Exception)
def parseIntsC: JsonC = parse(intsJson).getOrElse(throw new Exception)
@Benchmark
def parseIntsA: JsonA = Parse.parse(intsJson).getOrElse(throw new Exception)
@Benchmark
def parseFoosJ: JsonJ = parse(foosJson).getOrElse(throw new Exception)
def parseFoosC: JsonC = parse(foosJson).getOrElse(throw new Exception)
@Benchmark
def parseFoosA: JsonA = Parse.parse(foosJson).getOrElse(throw new Exception)
@@ -113,20 +113,20 @@ class ParsingBenchmark extends ExampleData {
*
* The following command will run the benchmarks with reasonable settings:
*
* > sbt "benchmark/run -i 10 -wi 10 -f 2 -t 1 io.jfc.benchmark.PrintingBenchmark"
* > sbt "benchmark/run -i 10 -wi 10 -f 2 -t 1 io.circe.benchmark.PrintingBenchmark"
*/
@State(Scope.Thread)
@BenchmarkMode(Array(Mode.Throughput))
@OutputTimeUnit(TimeUnit.SECONDS)
class PrintingBenchmark extends ExampleData {
@Benchmark
def printIntsJ: String = intsJ.noSpaces
def printIntsC: String = intsC.noSpaces
@Benchmark
def printIntsA: String = intsA.nospaces
@Benchmark
def printFoosJ: String = foosJ.noSpaces
def printFoosC: String = foosC.noSpaces
@Benchmark
def printFoosA: String = foosA.nospaces
Oops, something went wrong.

0 comments on commit 4c1fb72

Please sign in to comment.