Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mdedetrich/json4s-spire
Spire wrappers for Json4s
https://github.com/mdedetrich/json4s-spire
Last synced: 26 days ago
JSON representation
Spire wrappers for Json4s
- Host: GitHub
- URL: https://github.com/mdedetrich/json4s-spire
- Owner: mdedetrich
- License: other
- Created: 2014-07-16T07:29:05.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-01-15T08:10:04.000Z (almost 9 years ago)
- Last Synced: 2024-05-02T02:31:17.059Z (6 months ago)
- Language: Scala
- Size: 6.84 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# json4s-spire: Spire wrappers for Json4s
[json4s-spire][1] is a collection of sane wrappers for basic [spire][2] number types to [json4s][3] Json AST representation, allowing
you to easily decompose spire values to Json and extract Json values into spire values. It is built for scala 2.10 and scala 2.11.# Installation
Simply add the following dependency to `libraryDependencies`
"org.mdedetrich" %% "json4s-spire" % "1.3.0"
# Usage[json4s-spire][1] comes with 2 modes, `withDouble` and `withDecimal`. `withDouble` converts `JDouble` to relevant [spire][2] types and vice versa,
where as `withDecimal` converts `JDecimal` to relevant spire types and vice versaThe `implicit val fixedScale` is needed due to the [spire][2] `FixedPoint` type. If you need to change between different `FixedPoint`s, you need
to create a different [json4s][3] `Formats` for each case## withDecimal
```scala
implicit val fixedScale = FixedScale(10)
val formats = DefaultFormats.withBigDecimal ++ org.json4s.spire.Serializers.withDecimal
```## withDouble
```scala
implicit val fixedScale = FixedScale(10)
val formats = DefaultFormats.withBigDecimal ++ org.json4s.spire.Serializers.withDouble
```# TODO
* More non trivial test cases need to be added
[1]:https://github.com/mdedetrich/json4s-spire
[2]:https://github.com/non/spire
[3]:https://github.com/json4s/json4s