JSON Data Services
Combines multiple services to help working with json-data manipulation, synchronisation and validation.
- The
DataService
manages application state and retrieval. Additional supports undo. - The
ValidationService
validates any data by a given JSON-schema. - The
SchemaService
returns the JSON-schema at the given JSON-pointer location
All services offer an interface based on JSON-pointer.
Services
DataService
Data can only be changed via the data-service methods. Each state is tracked within the services, enabling und/redo functionality.
const dataService = new DataService(new State(), jsonData);
dataService.get("#/content/header/title");
Data manipulation methods
dataService.set(pointer, data);
dataService.delete(pointer, data);
dataService.undo();
dataService.redo();
DataService events
dataService.on("beforeUpdate", callback)
dataService.on("afterUpdate", callback)
dataService.observe(pointer, callback, true)
Dataservice event object
function callback(event) {}
{
action: "SET_DATA",
pointer: "#/pointer/location",
parentPointer: "#/pointer",
}
ValidationService
Sends error notifications on changed data.
const validationService = new ValidationService(new State(), jsonSchema)
validationService.on("beforeValidation", callback)
validationService.observe(pointer, callback, true)
validationService.on("afterValidation", callback)
validationService.validate(data).then((errors) => {})