@open-kappa/myjson
Version:
A simple JSON management library.
72 lines (71 loc) • 2.08 kB
TypeScript
import { MyJson } from "./myjsonImpl";
/**
* @brief Holder for generic values.
* Usually it is the leaf ot a JSON tree.
* @typeparam Value The type of the stored value.
*/
declare class MyJsonValue<Value> extends MyJson {
/** The stored value. */
private value;
/**
* @brief Constructor.
* @param {Value} value The default value.
* @param {boolean} isMandatory True if the object must appear in the
* hierarchy.
* @param {string} name The name of the object.
*/
constructor(value: Value, isMandatory: boolean, name: string);
/**
* @brief Get the value.
* @return {Value} The value.
*/
getValue(): Value;
/**
* @brief Set the value.
* @param {Value} value The value.
*/
setValue(value: Value): void;
/**
* @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 Clone this object.
* @return {MyJsonValue<Value>} The copy.
*/
clone(): MyJsonValue<Value>;
/**
* @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 Map to JSON.
* @return {Value} The value.
*/
toJSON(): Value;
/**
* @brief Clear the object content.
*/
protected clearImpl(): void;
/**
* @brief Merge the two objects.
* The values are replaced.
* @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): MyJson;
}
export { MyJsonValue };
export default MyJsonValue;