DynJson

scalus.utils.DynJson
See theDynJson companion object
final class DynJson(val value: Value) extends Dynamic

A lightweight wrapper around ujson.Value that uses Scala's Dynamic trait to enable dot-syntax navigation of JSON structures.

Instead of writing json("foo")("bar")(1).num, you can write json.dyn.foo.bar(1).num.

import scalus.utils.DynJson.*

val json = ujson.read("""{"foo": {"bar": [1, 2, 3]}}""")
json.dyn.foo.bar(1).num // 2.0

Throws the same exceptions as ujson.Value on missing keys or type mismatches. Use strOpt/numOpt/boolOpt for safe access.

Attributes

Companion
object
Graph
Supertypes
trait Dynamic
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def apply(index: Int): DynJson
def applyDynamic(name: String)(index: Int): DynJson
def arr: Arr
def arrOpt: Option[ArrayBuffer[Value]]
def bool: Boolean
def boolOpt: Option[Boolean]
def isNull: Boolean
def num: Double
def numOpt: Option[Double]
def obj: Obj
def objOpt: Option[LinkedHashMap[String, Value]]
def selectDynamic(name: String): DynJson
def str: String
def strOpt: Option[String]
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any

Concrete fields

val value: Value