JsonObjectBuilder

grapple.json.JsonObjectBuilder

Defines JSON object builder.

import scala.language.implicitConversions

import grapple.json.{ *, given }

val user = JsonObjectBuilder()
 .add("id", 1000)
 .add("name", "lupita")
 .add("groups", Set("lupita", "sudoer"))
 .toJsonObject()

assert { user("id").as[Int] == 1000 }
assert { user("name").as[String] == "lupita" }
assert { user("groups").as[Set[String]] == Set("lupita", "sudoer") }

Attributes

See also
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def add(key: String, value: String): JsonObjectBuilder.this.type

Adds field to JSON object.

Adds field to JSON object.

Attributes

Returns

this builder

def add(key: String, value: Boolean): JsonObjectBuilder.this.type

Adds field to JSON object.

Adds field to JSON object.

Attributes

Returns

this builder

def add(key: String, value: Int): JsonObjectBuilder.this.type

Adds field to JSON object.

Adds field to JSON object.

Attributes

Returns

this builder

def add(key: String, value: Long): JsonObjectBuilder.this.type

Adds field to JSON object.

Adds field to JSON object.

Attributes

Returns

this builder

def add(key: String, value: Float): JsonObjectBuilder.this.type

Adds field to JSON object.

Adds field to JSON object.

Attributes

Returns

this builder

def add(key: String, value: Double): JsonObjectBuilder.this.type

Adds field to JSON object.

Adds field to JSON object.

Attributes

Returns

this builder

def add(key: String, value: BigInt): JsonObjectBuilder.this.type

Adds field to JSON object.

Adds field to JSON object.

Attributes

Returns

this builder

def add(key: String, value: BigDecimal): JsonObjectBuilder.this.type

Adds field to JSON object.

Adds field to JSON object.

Attributes

Returns

this builder

def add(key: String, value: JsonValue): JsonObjectBuilder.this.type

Adds field to JSON object.

Adds field to JSON object.

Attributes

Returns

this builder

def addNull(key: String): JsonObjectBuilder.this.type

Adds field with null value to JSON object.

Adds field with null value to JSON object.

Attributes

Returns

this builder

Builds JSON object.

Builds JSON object.

Attributes