Skip to content

Commit

Permalink
Documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
tarao committed Dec 20, 2023
1 parent c9a0f1d commit a2e9153
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ ThisBuild / githubWorkflowAddedJobs ++= Seq(
ThisBuild / tlSitePublishBranch := None // update on tag releases
lazy val docs = project
.in(file("site"))
.dependsOn(core.jvm, circe.jvm)
.dependsOn(core.jvm, circe.jvm, upickle.jvm)
.enablePlugins(TypelevelSitePlugin)
.settings(
scalacOptions --= Seq(
Expand Down
38 changes: 38 additions & 0 deletions docs/integrations/upickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Integration with uPickle
========================

Records can be converted to/from JSON by using [uPickle][].

[uPickle]: https://com-lihaoyi.github.io/upickle/

Installation
------------

You need an additional module to use records integrated with [uPickle][].

```scala
libraryDependencies ++= Seq(
"com.github.tarao" %% "record4s-upickle" % "@VERSION@"
),
```

From / To JSON
--------------

Importing `Record.readWriter` enables [uPickle][] to decode/encode records in the ordinary way.

```scala mdoc:mline
import com.github.tarao.record4s.%
import com.github.tarao.record4s.upickle.Record.readWriter
import upickle.default.{read, write}

type Person = % { val name: String; val age: Int }

val json = """{"name":"tarao","age":3}"""

// Read from JSON
val r = read[Person](json)

// Write it back
write(r)
```

0 comments on commit a2e9153

Please sign in to comment.