final case class JsonPointer extends Product with Serializable
Contains the components making up a JSON Pointer.
The components that make up the path in a JSON Pointer are stored as a vector. Each component has had any escape characters replaced with the underlying character (~0 => ~, ~1 => /). A series of methods are provided that allow paths to be built and resolved.
The root path is represented by an empty JSON pointer:
JsonPointer()
Paths can be built up. For example
JsonPointer() / "items" / 0 / "name"
refers to the name
property stored in the zeroth element of the items
array.
Paths can be resolved against a JSON document:
JsonPointer.fromString("items/0/name").resolve( parse(""" { "items": [ {"name": "spanner"}, {"name", "hammer"}, {"name", "chisel" ] }""" ) )
would resolve to the value "spanner".
- Source
- JsonPointer.scala
- Alphabetic
- By Inheritance
- JsonPointer
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- def /(index: Int): JsonPointer
Appends a numeric component to an existing path.
Appends a numeric component to an existing path.
A numeric component identifies an entry in a JSON array. The index is zero based. The operator can be chained to build a complex pointer. This method is a synonym for the
append
method.Example:
JsonPointer() / "items" / 0 / "name"
- index
to be appended to existing path
- returns
new JsonPointer with updated path
- def /(token: String): JsonPointer
Appends a string component to an existing path.
Appends a string component to an existing path.
A string component identifies a property key in a JSON object. The operator can be chained to build a complex pointer. This method is a synonym for the
append
method.Example:
JsonPointer() / "person" / "name"
- token
component to be appended to existing path
- returns
new JsonPointer with updated path
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def append(index: Int): JsonPointer
Appends a numeric component to an existing path.
Appends a numeric component to an existing path.
A numeric component identifies an entry in a JSON array. The index is zero based. The operator can be chained to build a complex pointer. This method is a synonym for the
append
method.Example:
JsonPointer().append("items").append(0).append("name")
- index
to be appended to existing path
- returns
new JsonPointer with updated path
- def append(token: String): JsonPointer
Appends a string component to an existing path.
Appends a string component to an existing path.
A string component identifies a property key in a JSON object. The operator can be chained to build a complex pointer.
Example:
JsonPointer().append("person").append("name")
- token
component to be appended to existing path
- returns
new JsonPointer with updated path
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def get(json: JValue): Option[JValue]
Resolves a JSON Pointer path against a JSON document.
Resolves a JSON Pointer path against a JSON document.
The path contained as
tokens
is resovled against a given JSON document. If the path resolves to a JSON value then the value is returned wrapped in a Some, otherwise None is returned indicating a value does not exist for the path.- json
document against which to resolve the path
- returns
scala.None if the path cannot be resolved to a value otherwise the value wrapped in a Some
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def getOrElse(json: JValue, default: => JValue): JValue
Resolves a JSON Pointer against a JSON document.
Resolves a JSON Pointer against a JSON document.
If the path resolves to a JSON value then the value is returned otherwise the
default
JSON value is returned.- json
document against which to resolve the path
- default
value to return if path does not exist
- returns
JSON value path resolves to, otherwise
default
value
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def productElementNames: Iterator[String]
- Definition Classes
- Product
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
Provides a string representation of a JSON Pointer.
Provides a string representation of a JSON Pointer.
The string contains escaped characters if they appear in a path component. The escaped mappings are:
~ => ~0 / => ~1
Example:
JsonPointer("one", "two/three").toString
Output:
"/one/two~1three"
- returns
string representation of JSON Pointer
- Definition Classes
- JsonPointer → AnyRef → Any
- See also
"RFC 6901, section 5"
- val tokens: Vector[String]
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
Documentation for the Axiell Schema Project
Overview
The Axiell Schema Project provides a small library for validating JSON documents against a JSON Schema. The library conforms to the JSON Schema Draft #7 specification.
The library is based on a few simple principles, namely:
Package structure
The
packages consists of a number of utilities, where each utility provides a single piece of functionality. Since the library validates JSON structures two main components are provided. The first component (com.axiell.schema
) allows JSON documents conforming to the JSON Schema specification to be read. Once read a resolution process may be required to resolve any external references defined in the document.com.axiell.schema.Schema
The second component (
) takes a resolved schema and allows JSON documents to be validated against that schema. When creating a validator it is also possible to incorporate your own "format" types for validation.com.axiell.schema.SchemaValidator
A set of auxiliary components implement parsers for many of the "format" types and can be used independently of the validator itself.
Notable utilities are:
Schema
wrapper around a JSON document containing the document itself, its$id
value and resolution mappings for all$id
and$ref
directives.SchemaValidator
takes aSchema
and an optional handler for "format" types and provides a validation method for arbitrary JSON documents.Implicits
implements implicit methods and classes used to convert one class to another or pimp methods onto existing classes (e.g.same()
method toJValue
class).EmailAddress
Hostname
Ipv4Address
Ipv6Address
JsonPointer
RelativeJsonPointer
Dependencies
The list of dependencies are:
Axiell Util Library
provides error handling classes and methods that allow multilingual error messages to be generated.JSON for Scala Library
provides mthods for dealing with JSON structures. The routines work around an AST (Abstract Syntax Tree) used to represent a JSON document.Cats Functional Programming Library
provides various traits, classes and methods that simplify functional programming in Scala. Also provides theValidated
class used to return lists of validation errors.