JsonSource

com.eclipsesource.schema.JsonSource
object JsonSource

Convenience class for obtaining JSON values and Schemas from different sources.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
JsonSource.type

Members list

Value members

Concrete methods

def fromString(json: String): Try[JsValue]

Tries to parse the given JSON string.

Tries to parse the given JSON string.

Value parameters

json

the input string

Attributes

Returns

the result wrapped in a Try

def fromUrl(url: URL): Try[JsValue]

Fetches the content from the given URL and tries to parse the result as JSON.

Fetches the content from the given URL and tries to parse the result as JSON.

Value parameters

url

the URL at which a JSON instance is expected

Attributes

Returns

the result wrapped in a Try

def schemaFromStream(inputStream: InputStream)(implicit reads: Reads[SchemaType]): JsResult[SchemaType]

Tries to read from the given InputStream and convert the result to a JSON schema. Closes the stream in any case.

Tries to read from the given InputStream and convert the result to a JSON schema. Closes the stream in any case.

Value parameters

inputStream

the input string

Attributes

Returns

the read result wrapped in a JsResult

def schemaFromString(json: String)(implicit reads: Reads[SchemaType]): JsResult[SchemaType]

Tries to parse the given JSON string and convert it to a JSON schema.

Tries to parse the given JSON string and convert it to a JSON schema.

Value parameters

json

the input string

Attributes

Returns

the result wrapped in a JsResult

def schemaFromUrl(url: URL)(implicit reads: Reads[SchemaType]): JsResult[SchemaType]

Fetches the content from the given URL and tries to parse the result as a JSON schema.

Fetches the content from the given URL and tries to parse the result as a JSON schema.

Value parameters

url

the URL at which a JSON schema is expected

Attributes

Returns

the result wrapped in a JsResult