Open jdegoes opened 4 years ago
I think that the most common pattern of using Json AST directly is something like :
given JsonDecoder[ApiTransaction] = JsonDecoder[Json].map { json =>
val c = json.cursor // somehow perform multiple ops on the cursor like this
for {
id <- c.downField("id").as[TxId]
inputs <- c.downField("inputs").as[ArraySeq[ApiInput]]
dataInputs <- c.downField("dataInputs").as[List[ApiDataInput]]
outputs <- c.downField("outputs").as[ArraySeq[ApiOutput]]
size <- c.downField("size").as[Int]
} yield ApiTransaction(id, inputs, dataInputs, outputs, size)
Which is currently quite hard to put together and probably even inefficient.
final def transformAt[A <: Json](cursor: JsonCursor[_, A])(f: A => Json): Either[String, Json] = ???
final def delete(cursor: JsonCursor[_, _]): Either[String, Json] = ???
final def diff(that: Json): JsonDiff = JsonDiff(self, that)
final def intersect(that: Json): Either[String, Json] = ???
final def relocate(from: JsonCursor[_, _], to: JsonCursor[_, _]): Either[String, Json] = ???