Packages

  • package root
    Definition Classes
    root
  • package little
    Definition Classes
    root
  • package json
    Definition Classes
    little
  • package rpc

    Defines API for JSON-RPC 2.0.

    Defines API for JSON-RPC 2.0.

    import javax.json.JsonValue
    
    import little.json.{ Json, JsonAdapter }
    import little.json.Implicits._
    import little.json.rpc._
    
    case class Params(values: Int*)
    
    // Define adapter for converting params to and from JSON
    implicit object ParamsAdapter extends JsonAdapter[Params] {
      def reading(json: JsonValue): Params =
        Params(json.as[Seq[Int]] : _*)
    
      def writing(params: Params): JsonValue =
        Json.toJson(params.values)
    }
    
    // Create request with builder
    val request = JsonRpcRequest.builder()
      .version("2.0")
      .id("590d24ae-500a-486c-8d73-8035e78529bd")
      .method("sum")
      .params(Params(1, 2, 3))
      .build()
    
    // Initialize response builder
    val responseBuilder = JsonRpcResponse.builder()
      .version(request.version)
      .id(request.id)
    
    request.method match {
      case "sum" =>
        val params = request.params.get.as[Params]
    
        // Set result
        responseBuilder.result(params.values.sum)
      case name =>
        // Or set error
        responseBuilder.error(MethodNotFound(name))
    }
    
    // Create response with builder
    val response = responseBuilder.build()
    Definition Classes
    json
  • ArrayBuilderCompanion
  • ArrayContextWriter
  • BuilderCompanion
  • ContextWriter
  • Implicits
  • Json
  • JsonAdapter
  • JsonInput
  • JsonOutput
  • ObjectBuilderCompanion
  • ObjectContextWriter
o

little.json

Implicits

object Implicits

Provides type classes for javax.json and implicit implementations of JsonOutput and JsonInput.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Implicits
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. implicit final class JsonArrayBuilderType extends AnyVal

    Provides extension methods to javax.json.JsonArrayBuilder.

    Provides extension methods to javax.json.JsonArrayBuilder.

    See also

    JsonObjectBuilderType

  2. implicit final class JsonArrayType extends AnyVal

    Provides extension methods to javax.json.JsonArray.

    Provides extension methods to javax.json.JsonArray.

    See also

    JsonValueType, JsonObjectType

  3. implicit final class JsonGeneratorType extends AnyVal

    Provides extension methods to javax.json.stream.JsonGenerator.

    Provides extension methods to javax.json.stream.JsonGenerator.

    See also

    JsonParserType

  4. implicit final class JsonObjectBuilderType extends AnyVal

    Provides extension methods to javax.json.JsonObjectBuilder.

    Provides extension methods to javax.json.JsonObjectBuilder.

    See also

    JsonArrayBuilderType

  5. implicit final class JsonObjectType extends AnyVal

    Provides extension methods to javax.json.JsonObject.

    Provides extension methods to javax.json.JsonObject.

    See also

    JsonValueType, JsonArrayType

  6. implicit final class JsonParserType extends AnyVal

    Provides extension methods to javax.json.stream.JsonParser.

    Provides extension methods to javax.json.stream.JsonParser.

    See also

    JsonGeneratorType

  7. implicit final class JsonValueType extends AnyVal

    Provides extension methods to javax.json.JsonValue.

    Provides extension methods to javax.json.JsonValue.

    See also

    JsonArrayType, JsonObjectType

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. implicit def arrayJsonOutput[T](implicit output: JsonOutput[T]): JsonOutput[Array[T]]

    Creates JsonOutput for converting Array to JsonArray.

  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. implicit def asJson[T](value: T)(implicit output: JsonOutput[T]): JsonValue

    Converts value of type T to JsonValue.

  7. implicit val bigDecimalJsonInput: JsonInput[BigDecimal]

    Converts JsonValue to BigDecimal.

  8. implicit val bigDecimalJsonOutput: JsonOutput[BigDecimal]

    Converts BigDecimal to JsonValue.

  9. implicit val bigIntJsonInput: JsonInput[BigInt]

    Converts JsonValue to BigInt (exact).

  10. implicit val bigIntJsonOutput: JsonOutput[BigInt]

    Converts BigInt to JsonValue.

  11. implicit val booleanJsonInput: JsonInput[Boolean]

    Converts JsonValue to Boolean.

  12. implicit val booleanJsonOutput: JsonOutput[Boolean]

    Converts Boolean to JsonValue.

  13. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  14. implicit def collectionJsonInput[A, M[A]](implicit input: JsonInput[A], build: CanBuildFrom[Nothing, A, M[A]]): JsonInput[M[A]]

    Creates JsonInput for converting JsonArray to collection.

  15. implicit def containerAsJson[A, M[A]](value: M[A])(implicit output: JsonOutput[M[A]]): JsonValue

    Converts M[A] to JsonValue.

  16. implicit val doubleJsonInput: JsonInput[Double]

    Converts JsonValue to Double.

  17. implicit val doubleJsonOutput: JsonOutput[Double]

    Converts Double to JsonValue.

  18. implicit def eitherAsJson[A, B](value: Either[A, B])(implicit left: JsonOutput[A], right: JsonOutput[B]): JsonValue

    Converts Either[A, B] to JsonValue.

  19. implicit def eitherJsonInput[A, B](implicit left: JsonInput[A], right: JsonInput[B]): JsonInput[Either[A, B]]

    Creates JsonInput for converting JsonValue to Either.

    Creates JsonInput for converting JsonValue to Either.

    An attempt is made to first convert the value to Right value. If that attempt fails, then an attempt is made to convert it to Left value.

  20. implicit def eitherJsonOutput[A, B, M[A, B] <: Either[A, B]](implicit left: JsonOutput[A], right: JsonOutput[B]): JsonOutput[M[A, B]]

    Creates JsonOutput for converting Either to JsonValue.

  21. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  22. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  23. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  24. implicit val floatJsonInput: JsonInput[Float]

    Converts JsonValue to Float.

  25. implicit val floatJsonOutput: JsonOutput[Float]

    Converts Float to JsonValue.

  26. implicit def genTraversableOnceJsonOutput[A, M[A] <: GenTraversableOnce[A]](implicit output: JsonOutput[A]): JsonOutput[M[A]]

    Creates JsonOutput for converting GenTraversableOnce to JsonArray.

  27. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  28. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  29. implicit val intJsonInput: JsonInput[Int]

    Converts JsonValue to Int (exact).

  30. implicit val intJsonOutput: JsonOutput[Int]

    Converts Int to JsonValue.

  31. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  32. implicit val longJsonInput: JsonInput[Long]

    Converts JsonValue to Long (exact).

  33. implicit val longJsonOutput: JsonOutput[Long]

    Converts Long to JsonValue.

  34. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  35. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  36. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  37. implicit def optionJsonInput[T](implicit input: JsonInput[T]): JsonInput[Option[T]]

    Creates JsonInput for converting JsonValue to Option.

    Creates JsonInput for converting JsonValue to Option.

    The instance of JsonInput returns Some if the value is successfully converted, and None if the value is JSON null (i.e., JsonValue.NULL); otherwise it throws the exception thrown by the implicit input.

    Note: This behavior is different from JsonValueType.asOption, which returns Some if the value is successfully converted and returns None if the value is JSON null or if an exception was thrown during conversion.

  38. implicit def optionJsonOutput[A, M[A] <: Option[A]](implicit output: JsonOutput[A]): JsonOutput[M[A]]

    Creates JsonOutput for converting Option to JsonValue.

  39. implicit val shortJsonInput: JsonInput[Short]

    Converts JsonValue to Short (exact).

  40. implicit val shortJsonOutput: JsonOutput[Short]

    Converts Short to JsonValue.

  41. implicit def stringArrayAsJson(values: Array[String])(implicit output: JsonOutput[Array[String]]): JsonValue

    Converts Array[String] to JsonValue.

  42. implicit val stringJsonInput: JsonInput[String]

    Converts JsonValue to String.

  43. implicit val stringJsonOutput: JsonOutput[String]

    Converts String to JsonValue.

  44. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  45. def toString(): String
    Definition Classes
    AnyRef → Any
  46. implicit def tryJsonInput[T](implicit input: JsonInput[T]): JsonInput[Try[T]]

    Creates JsonInput for converting JsonValue to Try.

  47. implicit def tryJsonOutput[A, M[A] <: Try[A]](implicit output: JsonOutput[A]): JsonOutput[M[A]]

    Creates JsonOutput for converting Try to JsonValue.

  48. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  49. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  50. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped