package jsonld

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. Protected

Type Members

  1. final case class Base extends Product with Serializable

    A base URI renders as @base in a context.

  2. trait Binding extends AnyRef

    A binding represents a mapping between a BindingKey and a Node of some specific type.

    A binding represents a mapping between a BindingKey and a Node of some specific type.

    Bindings come from a Keyword or an IRIValue, using a bindFoo style, i.e. an IRIBinding is returned if bindIRI is used. Different bindings are possible on different keywords.

    Most of the documentation and exmaples are in the implementations.

  3. trait BindingKey extends AnyRef

    A binding key consists of a name and a binding operation defined by the instance.

  4. trait BlindsightASTMapping extends AnyRef

    Maps the root NodeObject to a BObject.

  5. sealed abstract class BooleanLiteral extends Value[Boolean] with LiteralValue[Boolean]

    Represents a JSON boolean literal.

  6. final case class CompactIRI extends IRIValue with Product with Serializable
  7. final case class IRI extends IRIValue with Product with Serializable

    This is a full IRI.

  8. final case class IRIBinding[T](key: IRIBindingKey)(implicit evidence$1: IRIValueMapper[T]) extends Binding with Product with Serializable

    A binding of a key to an IRIValue, returning a NodeEntry.

    A binding of a key to an IRIValue, returning a NodeEntry.

    This is most commonly used with keywords, i.e. @type:

    val `@type`   = Keyword.`@type`.bindIRI
    val givenName  = schemaOrg("givenName").bindValue[String]
    val personType = schemaOrg("Person")
    val willPerson = NodeObject(
      `@type` -> personType,
      givenName -> "Will"
    )

    A custom IRIValueMapper can be defined for a type. This can be particularly useful when referring by id:

    implicit val personIRIMapper: IRIValueMapper[Person] = IRIValueMapper(p => IRI(p.id))
    
    val id = exampleOrg("president").bindIRI[Person] // has @type -> @id
    val obama = Person("http://www.wikidata.org/entity/Q76", name = "Barack Obama")
    val america = NodeObject(
      president -> obama
    )
  9. trait IRIBindingKey extends BindingKey

    A binding key that returns an IRIBinding through bindIRI.

  10. sealed trait IRIValue extends Node with ValueBindingKey with IRIBindingKey with NodeObjectBindingKey with ListBindingKey with IndexMapBindingKey with TypeMapBindingKey with LanguageMapBindingKey with IdMapBindingKey with SetBindingKey

    An IRI value is any resource that expands out to an IRI, such as a term, a compact IRI.

    An IRI value is any resource that expands out to an IRI, such as a term, a compact IRI.

    See also

    IRIs

  11. trait IRIValueMapper[T] extends AnyRef

    This type class allows things that are not Terms/LongIRI/CompactIRI to be mapped.

    This type class allows things that are not Terms/LongIRI/CompactIRI to be mapped.

    See IRIBinding for example usage.

    T

    the type class instance

  12. final case class IRIsBinding[T](key: IRIBindingKey)(implicit evidence$2: IRIValueMapper[T]) extends Binding with Product with Serializable
  13. final case class IdMapBinding(key: BindingKey) extends Binding with Product with Serializable

    Index map that maps node objects as values, using property based values.

    Index map that maps node objects as values, using property based values.

    In property-based data indexing, index maps can only be used on node objects, not value objects or graph objects, so there is no ValueMapper equivalent.

    key

    the binding key for the map

  14. trait IdMapBindingKey extends BindingKey

    A binding key that returns an IdMapBinding.

  15. final case class IndexMapBinding(key: BindingKey) extends Binding with Product with Serializable

    Index map that maps node objects as values.

    Index map that maps node objects as values.

    Because this is an index map, the keys here are strings rather than binding keys.

    key

    the binding key for the map

    See also

    data indexing

  16. trait IndexMapBindingKey extends BindingKey

    A binding key that returns an IndexMapBinding.

  17. final case class JsonArrayLiteral(value: BArray) extends Value[BArray] with LiteralValue[BArray] with Product with Serializable

    A JSON literal value that returns a BArray.

    A JSON literal value that returns a BArray.

    value

    the array representing JSON literal objects.

    See also

    JSON Literals

  18. final case class JsonObjectLiteral(value: BObject) extends Value[BObject] with LiteralValue[BObject] with Product with Serializable

    A JSON literal value that returns a BObject.

    A JSON literal value that returns a BObject.

    value

    the object representing JSON.

    See also

    JSON Literals

  19. sealed trait Keyword[KeywordType <: Keyword[_]] extends AnyRef

    A keyword is a string that is specific to JSON-LD.

    A keyword is a string that is specific to JSON-LD.

    Different keywords have different key bindings available.

    See also

  20. final case class LanguageMapBinding(key: BindingKey) extends Binding with Product with Serializable

    https://www.w3.org/TR/json-ld11/#language-indexing

    https://www.w3.org/TR/json-ld11/#language-indexing

    https://www.w3.org/TR/json-ld11/#dfn-language-map

  21. trait LanguageMapBindingKey extends BindingKey

    A binding key that returns a LanguageMapBinding.

  22. final case class ListBinding[T](key: BindingKey)(implicit evidence$6: NodeMapper[T]) extends Binding with Product with Serializable

    A binding between a list object and a value.

    A binding between a list object and a value.

    val listOfStrings = schemaOrg("listOfStrings").bindList[String]
    
    val aListOfStrings = NodeObject(
     listOfStrings bind Seq("One", "Two", "Three", "Four")
    )

    You can resolve elements as null using an Option type:

    val optionalStrings = schemaOrg("optionalStrings").bindList[Option[String]]
    val obj = NodeObject(
     optionalStrings bind Seq(
       Some("some"),
       None,
     )
    )

    You can specify a list object to contain other list objects. For example, using the geometry example:

    trait MyGeoContext {
     val geojson   = IRI("https://purl.org/geojson/vocab#")
     val bbox    = geojson.term("bbox").bindList[Double]
     val geometry = geojson.term("geometry").bindObject[Geometry]
    
     implicit def seqMapper: NodeMapper[Seq[Double]] =
       NodeMapper { iter =>
         val mapper = implicitly[NodeMapper[Double]]
         ListObject(iter.map(mapper.mapNode))
       }
    
     val coordinates = vocab.term("coordinates").bindList[Seq[Double]]
    }
    
    final case class Geometry(`@type`: String, coords: Seq[Seq[Double]])
    
    object Geometry extends MyGeoContext {
     implicit val nodeMapper: NodeObjectMapper[Geometry] = NodeObjectMapper { geo =>
       val `@type`   = Keyword.`@type`.bindIRI
       NodeObject(
         `@type`     -> geo.`@type`,
         coordinates -> geo.coords
       )
     }
    }
    
    val geoFeatureNode = NodeObject(
     `@type` -> "Feature",
     bbox    -> Seq(-10.0, -10.0, 10.0, 10.0),
     geometry -> Geometry(
       "polygon",
       Seq(
         Seq(-10.0, -10.0),
         Seq(10.0, -10.0),
         Seq(10.0, 10.0),
         Seq(-10.0, 10.0)
       )
     )
    )
    T

    the node mapper type class instance

    key

    the binding key

    See also

    Lists

  23. trait ListBindingKey extends BindingKey

    A binding key that returns a ListBinding through bindList.

  24. final case class ListObject(value: Iterable[Node]) extends Node with Product with Serializable

    A list object.

    A list object. This is an ordered set of nodes.

    Note that a list is heterogeneous, so it may contain both node objects and json literals.

    value

    an iterable of Node

    See also

    Lists

  25. sealed trait LiteralValue[T] extends Value[T]

    A value that represents a literal type in JSON.

    A value that represents a literal type in JSON.

    T

    the underlying scala type.

  26. trait MapBinding extends Binding

  27. sealed trait Node extends AnyRef

    A Node is the base type for all elements, and is used for parsing.

    A Node is the base type for all elements, and is used for parsing.

    See also

    Uses of JSON objects

  28. final case class NodeEntry(key: String, value: Node*) extends Product with Serializable

    A node entry is used in the context of a NodeObject to indicate an [entry](https://infra.spec.whatwg.org/#map-entry).

    A node entry is used in the context of a NodeObject to indicate an [entry](https://infra.spec.whatwg.org/#map-entry).

    Note that although in most cases a entry key is an IRI value, in the case of an index map, the key is just a string.

    key

    the key of the node entry

    value

    the value of the node entry.

  29. trait NodeMapper[T] extends AnyRef

    This type class is used to map elements to a Node automatically.

    This type class is used to map elements to a Node automatically.

    Normally you won't need to implement this type class directly. It is used by the list and set mappers to convert other type class instances into Node.

    T

    the type class instance.

  30. final case class NodeObject(value: NodeEntry*) extends Node with Product with Serializable

    A node object contains node entries, represented as a Seq of NodeEntry.

    A node object contains node entries, represented as a Seq of NodeEntry.

    value

    a sequence of node entries.

    See also

    Node Objects

  31. final case class NodeObjectArrayBinding[T](key: BindingKey)(implicit evidence$8: NodeMapper[T]) extends Binding with Product with Serializable

    Used when you want to return an array of values but they are not list objects.

  32. final case class NodeObjectBinding[T](key: BindingKey)(implicit evidence$5: NodeObjectMapper[T]) extends Binding with Product with Serializable

    A binding between a key that is a "JSON-LD value" and a Scala type that can be represented as that value.

    A binding between a key that is a "JSON-LD value" and a Scala type that can be represented as that value. A NodeObjectMapper is responsible for doing the conversion.

    Most of the time you'll use a custom NodeObjectMapper to convert appropriately, building on other bindings in your context. For example, to render a MonetaryAmount class as a node object, you can add the binding in a context that contains currency and value bindings:

    case class MonetaryAmount(currency: Currency, value: Int)
    
    /** Represent as https://schema.org/MonetaryAmount instance */
    trait MonetaryAmountMapper extends MyContext {
      implicit val monetaryAmountMapper: NodeObjectMapper[MonetaryAmount] = NodeObjectMapper { ma =>
        NodeObject(
          `@type`  -> monetaryAmountType,
          currency -> ma.currency,
          value    -> ma.value
        )
      }
    }
    object MonetaryAmountMapper extends MonetaryAmountMapper

    And then you can use bindObject[MonetaryAmount].

    import MonetaryAmountMapper._
    
    val estimatedSalary: NodeObjectBinding[MonetaryAmount] =
     schemaOrg("estimatedSalary").bindObject[MonetaryAmount]

    You can also bind a simple NodeObject without mapping. For example, you can represent an organization with an employee as a raw NodeObject:

    val employee  = schemaOrg("employee").bindObject[NodeObject]
    val organization = NodeObject(
      `@type`   -> schemaOrg("Organization")
      name -> "Terse Systems",
      employee -> NodeObject(
        `@type`   -> schemaOrg("Person")
        givenName -> "Will",
      )
    )
  33. trait NodeObjectBindingKey extends BindingKey

    A binding key that returns a NodeObjectBinding using bindObject.

  34. trait NodeObjectMapper[T] extends AnyRef

    This type class is used to create NodeObject instances from given types.

    This type class is used to create NodeObject instances from given types.

    See NodeObjectBinding for example usage.

    T

    the type to convert to a NodeObject

  35. final case class NumberLiteral(value: Number) extends Value[Number] with LiteralValue[Number] with Product with Serializable

    Represents a JSON number literal.

    Represents a JSON number literal.

    value

    the number value.

  36. final case class PropertyIRI(name: String, base: IRI) extends IRIValue with Product with Serializable

    A Property IRI.

    A Property IRI. Unlike term, a property is a concatenation of the full IRI, rather than producing a minimal IRI.

    val niemCore = IRI("http://release.niem.gov/niem/niem-core/4.0/#")
    
    // prints "http://release.niem.gov/niem/niem-core/4.0/#PersonGivenName"
    val personGivenName = niemCore.property("PersonGivenName")
  37. final case class RelativeIRI(name: String, base: Base) extends IRIValue with Product with Serializable
  38. final case class SetBinding[T](key: BindingKey)(implicit evidence$7: NodeMapper[T]) extends Binding with Product with Serializable

    TODO fill this out

    TODO fill this out

    T

    the node mapper type class instance

    key

    the binding key

    See also

    Sets

  39. trait SetBindingKey extends BindingKey

    A binding key that returns a SetBinding through bindSet.

  40. final case class SetObject(value: Iterable[Node]) extends Node with Product with Serializable

    A set represents an unordered set of values.

    A set represents an unordered set of values.

    A set object does not represent a mathematical set, and so does not represent a scala Set. Instead, it's more like a "collection" of nodes.

    value

    an iteration of nodes.

    See also

    Lists and Sets

  41. sealed abstract class StringDirection extends AnyRef

    The string direction associated with the string.

  42. final case class StringLiteral(value: String) extends Value[String] with LiteralValue[String] with Product with Serializable

    Represents a JSON string literal.

    Represents a JSON string literal.

    value

    the string value.

  43. final case class StringValue(value: String, direction: Option[StringDirection] = None, lang: Option[String] = None) extends Value[String] with Product with Serializable

    A string value that is a value object that can contain a @direction and a @lang.

    A string value that is a value object that can contain a @direction and a @lang.

    value

    the string value

    direction

    the direction

    lang

    the locale, only getLanguage is used.

    See also

    Value Objects

  44. final case class Term extends Product with Serializable

    A term is a short-hand string that expands to an IRI, blank node identifier, or keyword.

    A term is a short-hand string that expands to an IRI, blank node identifier, or keyword.

    https://www.w3.org/TR/json-ld11/#terms

  45. final case class TypeMapBinding(key: BindingKey) extends Binding with Product with Serializable

    A type map is a map value of a term defined with @container set to @type, whose keys are interpreted as IRIs representing the @type of the associated node object.

    A type map is a map value of a term defined with @container set to @type, whose keys are interpreted as IRIs representing the @type of the associated node object.

    Definition

    The value must be a node object, or array of node objects, so there is no ValueMapper equivalent here.

    key

    the binding key for the map

  46. trait TypeMapBindingKey extends BindingKey

    A binding key that returns an TypeMapBinding.

  47. final case class TypedValue(value: String, valueType: IRIValue) extends Value[String] with Product with Serializable

    A typed value is a value associated with a IRI indicating the type's value.

    A typed value is a value associated with a IRI indicating the type's value.

    This is most often used for representing objects that do not have a single JSON representation, such as dates.

    value

    the string representation of the value

    valueType

    the IRI type of the value

    See also

    Typed Values

  48. sealed abstract class Value[T] extends Node

    A value is an approximation for a JSON-LD value, which can be a native JSON literal (string, number, boolean) or a JSON object (value object, typed value).

    A value is an approximation for a JSON-LD value, which can be a native JSON literal (string, number, boolean) or a JSON object (value object, typed value). In the case of strings with a direction or a language, the string value may be a value object rather than a JSON literal.

    This is a sealed abstract class because JSON-LD has a fixed number of values.

    You will normally use a value constructor rather than the specific instances, i.e.

    val stringValue: Value[String] = Value("some string")
    val numValue: Value[Int] = Value(1)
    T

    the underlying scala type.

  49. final case class ValueArrayBinding[T](key: BindingKey)(implicit evidence$4: NodeMapper[T]) extends Binding with Product with Serializable

    Used when you want to return an array of values but they are not list objects.

  50. final case class ValueBinding[T](key: ValueBindingKey)(implicit evidence$3: ValueMapper[T]) extends Binding with Product with Serializable

    A binding between a key that is a "JSON-LD value" and a Scala type that can be represented as that value.

    A binding between a key that is a "JSON-LD value" and a Scala type that can be represented as that value. A ValueMapper is responsible for doing the conversion.

    You can define your own ValueMapper for custom types, and primitives (String, Int, etc) are already defined:

    val givenName  = schemaOrg("givenName").bindValue[String]
    val willPerson = NodeObject(
      givenName    -> "Person"
    )

    Using a "null" is done by binding to an Option[T] of the type you want:

    val givenName  = schemaOrg("givenName").bindValue[Option[String]]
    val willPerson = NodeObject(
      givenName  -> None
    )

    Some JSON-LD values are represented as "value objects", notably strings with languages and typed values.

    To represent a string value:

    val givenName  = schemaOrg("givenName").bindValue[String]
    val willPerson = NodeObject(
      givenName -> Value("Will", StringDirection.LeftToRight, "en"),
    )

    You can require string values over literals by binding explicitly:

    val givenName  = schemaOrg("givenName").bindValue[StringValue]

    Likewise typed values are usually converted but can be defined explicitly:

    val name        = schemaOrg("name").bindValue[String]
    val dateCreated = schemaOrg("dateCreated").bindValue[TypedValue]
    val localDate = LocalDate.of(2020, 1, 1)
    val abridgedMobyDick = NodeObject(
      `@type`     -> "Book",
      name        -> "Moby Dick",
      dateCreated -> Value(DateTimeFormatter.ISO_DATE.format(localDate), xsdDate)
    )

    You can map any type to a value using a custom ValueMapper:

    val `@type` = Keyword.`@type`.bindIRI
    val schemaOrg: Vocab        = IRI("https://schema.org/").vocab
    val name: ValueBinding[String] = schemaOrg("name").bindValue[String]
    val value: ValueBinding[Int]   = schemaOrg("value").bindValue[Int]
    
    implicit val currencyMapper: ValueMapper[Currency] = ValueMapper { currency =>
      Value(currency.getCurrencyCode)
    }
    val currency: ValueBinding[Currency] = schemaOrg("currency").bindValue[Currency]
    T

    the type which has a ValueMapper type class instance

    key

    the value binding key

  51. trait ValueBindingKey extends BindingKey

    A binding key that returns a ValueBinding using bindValue.

  52. trait ValueMapper[T] extends AnyRef

    This type class is used to create Value instances from given types.

    This type class is used to create Value instances from given types.

    There are types provided for all the JSON-LD primitives and typed values.

    See ValueBinding for example usage

    T

    the type class instance.

  53. final case class Vocab extends Product with Serializable

    Creates keys that do not contain any prefix.

    Creates keys that do not contain any prefix.

    val niemCore = IRI("http://release.niem.gov/niem/niem-core/4.0/#")
    
    // "@vocab": "http://release.niem.gov/niem/niem-core/4.0/#"
    val ncVocab = niemCore.vocab
    
    // "PersonGivenName" without prefix
    val personGivenName = ncVocab("PersonGivenName")
  54. final case class VocabProperty(value: String, vocab: Vocab) extends IRIValue with Product with Serializable

    A vocab property is a property that was created from the default vocabulary.

    A vocab property is a property that was created from the default vocabulary.

    value

    the property name

    vocab

    the default vocabulary

Value Members

  1. object BlindsightASTMapping extends BlindsightASTMapping
  2. object BooleanLiteral
  3. object IRI extends Serializable
  4. object IRIValueMapper
  5. object IdMapBinding extends Serializable
  6. object IndexMapBinding extends Serializable
  7. object Keyword

    Contains all the keywords defined in document.

  8. object LanguageMapBinding extends Serializable
  9. object ListObject extends Serializable
  10. object Node
  11. object NodeEntry extends Serializable
  12. object NodeMapper
  13. object NodeObject extends Serializable
  14. object NodeObjectMapper
  15. case object NullLiteral extends Value[None.type] with LiteralValue[None.type] with Product with Serializable

    The literal representing null in a value.

    The literal representing null in a value.

    This is mapped to None so that it works more intuitively with optional values.

  16. object SetObject extends Serializable
  17. object StringDirection
  18. object TypeMapBinding extends Serializable
  19. object Value
  20. object ValueMapper

Ungrouped