@@ -22,10 +22,11 @@ low-level data items one would use this approach:
22
22
But on a slightly higher level the ` Writer ` also gives you a way to write arrays (and maps) without having distinguish
23
23
between [ CBOR] and [ JSON] yourself:
24
24
25
- @@snip [ -] ( $test$/JsonSpecificsSpec.scala ) { #writeArrayOpen-close }
25
+ @@snip [ -] ( $test$/JsonSpecificsSpec.scala ) { #writeArrayOpen-close }
26
26
27
27
As long as you rely on the somewhat higher-level parts of the ` Reader ` and ` Writer ` APIs or construct your
28
- (de)serialization purely logic from _ borer_ 's built-in or (and/or @ref :[ derived] ( ../borer-derivation/index.md ) ) Encoders and
28
+ (de)serialization purely logic from _ borer_ 's built-in or (and/or @ref :[ derived] ( ../borer-derivation/index.md ) ) Encoders
29
+ and
29
30
Decoders, your application will support both [ CBOR] and [ JSON] at the same time without any special casing whatsoever.
30
31
31
32
@@ -38,7 +39,7 @@ This is typically worked around by mapping binary data to a "Base Encoding", e.g
38
39
In order to give your application an easy and flexible way to integrate with other systems _ borer_ supports a number
39
40
of base encodings out of the box, specifically:
40
41
41
- - [ base16] ( https://tools.ietf.org/html/rfc4648#section-8 )
42
+ - [ base16] ( https://tools.ietf.org/html/rfc4648#section-8 )
42
43
- [ base32] ( https://tools.ietf.org/html/rfc4648#section-6 )
43
44
- [ base32hex] ( https://tools.ietf.org/html/rfc4648#section-7 )
44
45
- [ base32crockford] ( https://en.wikipedia.org/wiki/Base32#Crockford's_Base32 )
@@ -53,6 +54,15 @@ In order to switch to a different base encoding in a particular scope define the
53
54
@@snip [ -] ( $test$/JsonSpecificsSpec.scala ) { #alternative-base-encoding }
54
55
55
56
57
+ JSON Pretty Printing
58
+ --------------------
59
+
60
+ Normally _ borer_ will output JSON in the most compact form, with no whitespace padding anywhere.
61
+ However, you can enable "pretty" JSON rendering as shown here:
62
+
63
+ @@snip [ -] ( $test$/JsonSpecificsSpec.scala ) { #json-pretty-printing }
64
+
65
+
56
66
When (not) to use _ borer_ for JSON
57
67
----------------------------------
58
68
@@ -67,15 +77,6 @@ However, if all you need is an efficient way to convert raw network- or disk-byt
67
77
from your data model types, with no (or few) dependencies and maybe even with the option to target [ CBOR] with no
68
78
additional work required from your side, then _ borer_ should be a good choice.
69
79
70
- @@@ note
71
-
72
- Since _ borer_ doesn't really work with ` String ` and ` Char ` , but rather raw bytes only, it also doesn't support
73
- encoding to a "pretty", i.e. nicely formatted, JSON representation.<br >
74
- _ borer_ always outputs [ JSON] in the most compact form.
75
- (It can, of course, read "pretty" [ JSON] documents without any issue.)
76
-
77
- @@@
78
-
79
80
80
81
Comparison with other Scala JSON Libraries
81
82
------------------------------------------
@@ -88,7 +89,7 @@ Comparison with other Scala JSON Libraries
88
89
: AST/DOM- and type-class-based design
89
90
90
91
@@@ div { .pros }
91
-
92
+
92
93
- very mature
93
94
- allows for extensive DOM-manipulation
94
95
- many integration option already available
@@ -111,7 +112,7 @@ Comparison with other Scala JSON Libraries
111
112
: AST/DOM- and type-class-based design
112
113
113
114
@@@ div { .pros }
114
-
115
+
115
116
- zero dependencies
116
117
117
118
@@@
@@ -137,7 +138,7 @@ Comparison with other Scala JSON Libraries
137
138
@@@ div { .pros }
138
139
139
140
- zero dependencies
140
- - optional DOM
141
+ - optional DOM
141
142
- also supports [ MessagePack]
142
143
- compatible with [ scala.js]
143
144
@@ -150,7 +151,7 @@ Comparison with other Scala JSON Libraries
150
151
- _ borer_ decodes [ JSON] more than 4 times as fast
151
152
- no [ Scala Native] support
152
153
- no [ CBOR] support
153
-
154
+
154
155
@@@
155
156
156
157
---
@@ -166,7 +167,7 @@ Comparison with other Scala JSON Libraries
166
167
@@@
167
168
168
169
@@@ div { .cons }
169
-
170
+
170
171
- no type class-based API
171
172
- several non-Scala dependencies
172
173
- not compatible with [ scala.js] and [ Scala Native]
@@ -200,15 +201,26 @@ Comparison with other Scala JSON Libraries
200
201
201
202
---
202
203
203
- [ CBOR ] : https://cbor.io/
204
- [ JSON ] : https://json.org/
205
- [ RFC 4648 ] : https://tools.ietf.org/html/rfc4648
206
- [ base64 ] : https://tools.ietf.org/html/rfc4648#section-4
207
- [ Circe ] : https://circe.github.io/circe/
208
- [ spray-json ] : https://github.com/spray/spray-json/
209
- [ json-benchmark-files ] : https://github.com/sirthias/borer/tree/master/benchmarks/src/main/resources
210
- [ Jackson Scala ] : https://github.com/FasterXML/jackson-module-scala
211
- [ µPickle ] : https://com-lihaoyi.github.io/upickle/
212
- [ Jsoniter Scala ] : https://github.com/plokhotnyuk/jsoniter-scala
213
- [ MessagePack ] : https://msgpack.org/
214
- [ scala.js ] : https://www.scala-js.org/
204
+ [ CBOR ] : https://cbor.io/
205
+
206
+ [ JSON ] : https://json.org/
207
+
208
+ [ RFC 4648 ] : https://tools.ietf.org/html/rfc4648
209
+
210
+ [ base64 ] : https://tools.ietf.org/html/rfc4648#section-4
211
+
212
+ [ Circe ] : https://circe.github.io/circe/
213
+
214
+ [ spray-json ] : https://github.com/spray/spray-json/
215
+
216
+ [ json-benchmark-files ] : https://github.com/sirthias/borer/tree/master/benchmarks/src/main/resources
217
+
218
+ [ Jackson Scala ] : https://github.com/FasterXML/jackson-module-scala
219
+
220
+ [ µPickle ] : https://com-lihaoyi.github.io/upickle/
221
+
222
+ [ Jsoniter Scala ] : https://github.com/plokhotnyuk/jsoniter-scala
223
+
224
+ [ MessagePack ] : https://msgpack.org/
225
+
226
+ [ scala.js ] : https://www.scala-js.org/
0 commit comments