Object/Trait

com.rayrobdod.json.union

JsonValue

Related Docs: trait JsonValue | package union

Permalink

object JsonValue

The cases of JsonValue and methods to convert other things into JsonValues.

Source
JsonValue.scala
Since

3.0

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

Type Members

  1. final case class JsonValueBoolean(b: Boolean) extends JsonValue with Product with Serializable

    Permalink
  2. final case class JsonValueNumber(value: BigDecimal) extends JsonValue with Product with Serializable

    Permalink
  3. final case class JsonValueString(s: String) extends JsonValue with Product with Serializable

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. object JsonValueNull extends JsonValue

    Permalink
  5. implicit def apply(i: BigDecimal): JsonValue

    Permalink
  6. implicit def apply(b: Boolean): JsonValue

    Permalink
  7. implicit def apply(s: String): JsonValue

    Permalink
  8. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  9. def cborValue2JsonValueEither(x: CborValue): Either[Either[Array[Byte], Rational], JsonValue]

    Permalink

    Convert a CborValue into a JsonValue if there is an equivalent JsonValue; otherwise return a Left containing the incompatible value

    Convert a CborValue into a JsonValue if there is an equivalent JsonValue; otherwise return a Left containing the incompatible value

    Examples:
    1. // Declaring the failure to convert, with no attempts to post-fix
      val cbor:CborValue = ???
      val jsonEither = JsonValue.cborValue2JsonValueEither(cbor).fold(
      	{x => BuilderFailure(TypeCoercionFailure, ())},
      	{x => Complex(x)}
      )
    2. ,
    3. // With attempts to convert the incompatible values to something that will fit into a JsonValue
      import java.nio.charset.StandardCharsets.US_ASCII;
      val cbor:CborValue = ???
      val json:JsonValue = JsonValue.cborValue2JsonValueEither(cbor).fold(
      	{_.fold(
      		// in this example, base64-encode any ByteStrings
      		{x => JsonValueString(new String(java.util.Base64.getEncoder.encode(x), US_ASCII))},
      		// in this example, convert infinite values and nan to null, and round any other value
      		{x => x match {
      			case Rational.NaN => JsonValueNull
      			case Rational.PositiveInfinity => JsonValueNull
      			case Rational.NegativeInfinity => JsonValueNull
      			case x => x.toDouble
      		}}
      	)},
      	{x => x}
      )
    Since

    3.1

  10. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  11. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  12. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  13. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  14. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  15. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  16. implicit def implicitlyBigDecimal2JsonValue[A](a: A)(implicit ev: (A) ⇒ BigDecimal): JsonValue

    Permalink

    Allows implicit conversions from Int or Double directly to JsonValue

    Allows implicit conversions from Int or Double directly to JsonValue

    Since

    3.1

  17. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  18. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  19. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  20. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  21. implicit def stringOrInt2JsonValue(s: StringOrInt): JsonValue

    Permalink

    Convert a StringOrInt value into a JsonValue

  22. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  23. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  24. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def cborValueHexencodeByteStr(x: CborValue): JsonValue

    Permalink

    Convert a CborValue into a JsonValue, where ByteStrs are instead converted into hexencoded strings.

    Convert a CborValue into a JsonValue, where ByteStrs are instead converted into hexencoded strings.

    Annotations
    @deprecated
    Deprecated

    (Since version 3.1) doesn't handle incompatible numbers; use cborValue2JsonValueEither then fold that method's return value

Inherited from AnyRef

Inherited from Any

Ungrouped