You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/index.mdx
+122-53
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,9 @@ title: "Getting Started with ZIO Json"
4
4
sidebar_label: "Getting Started"
5
5
---
6
6
7
+
importTabsfrom'@theme/Tabs';
8
+
importTabItemfrom'@theme/TabItem';
9
+
7
10
[ZIO Json](https://github.com/zio/zio-json) is a fast and secure JSON library with tight ZIO integration.
8
11
9
12
@PROJECT_BADGES@
@@ -34,10 +37,23 @@ Let's try a simple example of encoding and decoding JSON using ZIO JSON.
34
37
35
38
All the following code snippets assume that the following imports have been declared
36
39
40
+
<TabsgroupId="language">
41
+
<TabItemvalue="scala 2"label="Scala 2">
42
+
37
43
```scala
38
44
importzio.json._
39
45
```
40
46
47
+
</TabItem>
48
+
<TabItemvalue="scala 3"label="Scala 3"default>
49
+
50
+
```scala
51
+
importzio.json.*
52
+
```
53
+
54
+
</TabItem>
55
+
</Tabs>
56
+
41
57
Say we want to be able to read some JSON like
42
58
43
59
```json
@@ -50,21 +66,30 @@ into a Scala `case class`
50
66
caseclassBanana(curvature: Double)
51
67
```
52
68
69
+
<TabsgroupId="language">
70
+
<TabItemvalue="scala 2"label="Scala 2">
71
+
72
+
To do this, we create an *instance* of the `JsonDecoder` typeclass for `Banana` using the `zio-json` code generator. It is best practice to put it on the companion of `Banana`, like so
Extreme **performance** is achieved by decoding JSON directly from the input source into business objects (inspired by [plokhotnyuk](https://github.com/plokhotnyuk/jsoniter-scala)). Although not a requirement, the latest advances in [Java Loom](https://wiki.openjdk.java.net/display/loom/Main) can be used to support arbitrarily large payloads with near-zero overhead.
0 commit comments