@open-kappa/myjson
Version:
A simple JSON management library.
76 lines (75 loc) • 2.58 kB
TypeScript
import { MyJson, MyJsonBaseObject } from "./myjsonImpl";
/**
* @brief A generic JSON object, with a fixed set of elements.
*/
declare class MyJsonFixed extends MyJsonBaseObject {
/**
* @brief Constructor.
* @param {boolean} isMandatory True if the object must appear in the
* hierarchy.
* @param {string} name The name of the object.
*/
constructor(isMandatory: boolean, name: string);
/**
* @brief Parse a JSON object.
* @param {any} json The JSON to parse.
* @throws {Error} If a validation error occurrs.
*/
protected parseJsonImpl(json: any): void;
/**
* @brief Clear the object content.
*/
protected clearImpl(): void;
/**
* @brief Clone this object.
* @return {MyJsonFixed} The copy.
*/
clone(): MyJsonFixed;
/**
* @brief Check if two JSON objects are equals.
* @param {MyJson} other The other object of comparison.
* @return {boolean} True if they are equals.
*/
isEqual(other: MyJson): boolean;
/**
* @brief Parse and validate internal elements.
* @private
* @param {any} json The json to parse.
* @throws {Error} If the parsing fails.
*/
private _validateJsonValues;
/**
* @brief Ensure required fproperties exist.
* @private
* @param {any} json The json to parse.
* @throws {Error} If the validation fails.
*/
private _ensureRequiredValues;
/**
* @brief Execute the given callback on each element.
* The callback takes the key, the element, and the whole object.
* It returns true to break the loop before having rolled on all elements.
* @param {(key:string,value:MyJson,obj:MyJsonFixed)=>boolean} func
* The callback.
* @param {any | null | undefined} [funcThis=null] The optional "this" for
* the callback.
*/
forEach(func: (key: string, value: MyJson, obj: MyJsonFixed) => boolean, funcThis?: any | null | undefined): boolean;
/**
* @brief Merge the two objects.
* Already existent keys are merged recursively.
* @param {MyJson} other The other object to merge.
* @throws {Error} If the two objects cannot be merged.
*/
merge(other: MyJson): void;
/**
* @brief Add a new child element.
* This is a build-time support method.
* @param {MyJson} element The child element.
* @return {MyJson} This.
* @throws {Error} If element cannot be added.
*/
add(element: MyJson): MyJsonFixed;
}
export { MyJsonFixed };
export default MyJsonFixed;