@@ -147,6 +147,43 @@ class ApiController @Inject()(couchbase: Couchbase)
147
147
}
148
148
```
149
149
150
+ ## What if I want to use a JSON lib other than Play Json ?
151
+
152
+ you can easily do that, actually everything linked to Play Json is imported from
153
+
154
+ ``` scala
155
+ import org .reactivecouchbase .rs .scaladsl .json ._
156
+ ```
157
+
158
+ then you just have to reimplement a few things
159
+
160
+ ``` scala
161
+ import akka .util .ByteString
162
+ import com .couchbase .client .java .document .json .JsonObject
163
+ import org .reactivecouchbase .rs .scaladsl .json .{JsonReads , JsonWrites , JsonSuccess , QueryParams }
164
+ import foo .bar .jsonlib .{JsonNode , JsonObj }
165
+
166
+ val read : JsonReads [JsonNode ] = JsonReads (bs => JsonSuccess (JsonNode .parse(bs.utf8String)))
167
+ val write : JsonWrites [JsonNode ] = JsonWrites (jsv => ByteString (JsonNode .stringify(jsv)))
168
+
169
+ implicit val defaultByteStringFormat : JsonFormat [JsonNode ] = JsonFormat (read, write)
170
+
171
+ implicit val defaultByteStringConverter : CouchbaseJsonDocConverter [JsonNode ] = new CouchbaseJsonDocConverter [JsonNode ] {
172
+ override def convert (ref : AnyRef ): JsonNode = ...
173
+ }
174
+
175
+ case class JsonObjQueryParams (query : JsonObj = ByteString .empty) extends QueryParams {
176
+ override def isEmpty : Boolean = ! query.hasValue
177
+ override def toJsonObject : JsonObject = ...
178
+ }
179
+ ```
180
+
181
+ You have a few examples at
182
+
183
+ * https://github.com/ReactiveCouchbase/reactivecouchbase-rs-core/blob/master/src/main/scala/org/reactivecouchbase/rs/scaladsl/json/package.scala
184
+ * https://github.com/ReactiveCouchbase/reactivecouchbase-rs-core/blob/master/src/main/scala/org/reactivecouchbase/rs/scaladsl/json/bytestring.scala
185
+ * https://github.com/ReactiveCouchbase/reactivecouchbase-rs-core/blob/master/src/main/scala/org/reactivecouchbase/rs/scaladsl/json/converter.scala#L21-L31
186
+
150
187
# Projects
151
188
152
189
The core of ReactiveCouchbase RS is available on Gihtub and depends on Play Json library and Akka Streams
0 commit comments