JSON decoding result

Report a typo

Write an ADT that will describe the result of parsing a JSON string. The result can either be an failure with its text or a successful value with Json.

There is already a Json class in the task space. And you also don't have to implemnt parse function.

But the following code must compile without warnings:

def parse(s: String): DecodeResult = ???

val json: Json = parse("""{"name":"Alice"}""") match
  case DecodeResult.Failure(error) => throw RuntimeException(error)
  case DecodeResult.Success(json)  => json

Sample Input 1:

Sample Output 1:

Write a program in Scala 3
// define your DecodeResult here
___

Create a free account to access the full topic