Json
Provides JSON utilities.
import scala.language.implicitConversions
import grapple.json.{ *, given }
// Create JSON object
val user = Json.obj("id" -> 1000, "name" -> "lupita")
// Create JSON array
val info = Json.arr(user, "/home/lupita", 8L * 1024 * 1024 * 1024)
// Parse JSON text
val root = Json.parse("""{ "id": 0, "name": "root" }""")
case class User(id: Int, name: String)
given userOutput: JsonOutput[User] with
def write(u: User) = Json.obj("id" -> u.id, "name" -> u.name)
// Convert value to JSON object
val nobody = Json.toJson(User(65534, "nobody"))
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Json.type
Members list
Value members
Concrete methods
Creates JSON array with supplied values.
Creates JSON array with supplied values.
Attributes
Creates JSON object with supplied fields.
Creates JSON object with supplied fields.
Attributes
Parses JSON structure from input.
Parses JSON structure from input.
Attributes
- Throws
-
JsonParserError
if input cannot be parsed to JSON structure
Parses JSON structure from input.
Parses JSON structure from input.
Attributes
- Throws
-
JsonParserError
if input cannot be parsed to JSON structure
Parses JSON structure from input.
Parses JSON structure from input.
Attributes
- Throws
-
JsonParserError
if input cannot be parsed to JSON structure
Parses JSON structure from input.
Parses JSON structure from input.
Attributes
- Throws
-
JsonParserError
if input cannot be parsed to JSON structure
- Note
-
Closes input on return.
Parses JSON structure from input.
Parses JSON structure from input.
Attributes
- Throws
-
JsonParserError
if input cannot be parsed to JSON structure
- Note
-
Closes input on return.
Parses JSON structure from input.
Parses JSON structure from input.
Attributes
- Throws
-
JsonParserError
if input cannot be parsed to JSON structure
Parses JSON structure from input.
Parses JSON structure from input.
Attributes
- Throws
-
JsonParserError
if input cannot be parsed to JSON structure
Converts JSON value to UTF-8 encoded bytes.
Converts JSON value to UTF-8 encoded bytes.
Attributes
Converts value to JSON value.
Converts value to JSON value.
Value parameters
- output
-
converter
- value
-
value
Attributes
Creates "pretty" print of JSON using 2-space indent.
Creates "pretty" print of JSON using 2-space indent.
Attributes
- Note
-
If value is not a JSON structure, identation is not used and the output is equivalent to
value.toString()
.
Creates "pretty" print of JSON using supplied indent.
Creates "pretty" print of JSON using supplied indent.
Attributes
- Note
-
If value is not a JSON structure, identation is not used and the output is equivalent to
value.toString()
.