export type { JsonObject as Object, JsonArray as Array }; /** * JSON data types, as returned by `JSON.parse()`. * * @category Utilities: JSON */ export type Value = null | boolean | number | string | JsonObject | JsonArray; /** * JSON object values. * * @category Utilities: JSON */ interface JsonObject extends Record { } /** * JSON array values. * * @category Utilities: JSON */ interface JsonArray extends Array { } /** * Tests a JSON value to see if it is `null`. * * @param x - JSON Value * @returns true if null; false otherwise * * @category Utilities: JSON */ export declare function isNull(x: Value): x is null; /** * Cast a JSON value to `null`, throwing a `JsonError` if the cast fails. * * @param x - JSON value to cast * @param prefix - optional error message prefix * @returns null * @throws {@link JsonError} if the cast fails * * @category Utilities: JSON */ export declare function asNull(x: Value, prefix?: string): null; /** * Tests a JSON value to see if it is a boolean. * * @param x - JSON Value * @returns true if null; false otherwise * * @category Utilities: JSON */ export declare function isJsonBoolean(x: Value): x is boolean; /** * Cast a JSON value to `boolean`, throwing a `JsonError` if the cast fails. * * @param x - JSON value to cast * @param prefix - optional error message prefix * @returns boolean * @throws {@link JsonError} if the cast fails * * @category Utilities: JSON */ export declare function asBoolean(x: Value, prefix?: string): boolean; /** * Tests a JSON value to see if it is a number. * * @param x - JSON Value * @returns true if null; false otherwise * * @category Utilities: JSON */ export declare function isJsonNumber(x: Value): x is number; /** * Cast a JSON value to `number`, throwing a `JsonError` if the cast fails. * * @param x - JSON value to cast * @param prefix - optional error message prefix * @returns number * @throws {@link JsonError} if the cast fails * * @category Utilities: JSON */ export declare function asNumber(x: Value, prefix?: string): number; /** * Tests a JSON value to see if it is a string. * * @param x - JSON Value * @returns true if null; false otherwise * * @category Utilities: JSON */ export declare function isJsonString(x: Value): x is string; /** * Cast a JSON value to `string`, throwing a `JsonError` if the cast fails. * * @param x - JSON value to cast * @param prefix - optional error message prefix * @returns string * @throws {@link JsonError} if the cast fails * * @category Utilities: JSON */ export declare function asString(x: Value, prefix?: string): string; /** * Tests a JSON value to see if it is a JSON object. * * @param x - JSON Value * @returns true if null; false otherwise * * @category Utilities: JSON */ export declare function isJsonObject(x: Value): x is JsonObject; /** * Cast a JSON value to `Object`, throwing a `JsonError` if the cast fails. * * @param x - JSON value to cast * @param prefix - optional error message prefix * @returns JsonObject * @throws {@link JsonError} if the cast fails * * @category Utilities: JSON */ export declare function asObject(x: Value, prefix?: string): JsonObject; /** * Tests a JSON value to see if it is a JSON array. * * @param x - JSON Value * @returns true if array; false otherwise * * @category Utilities: JSON */ export declare function isJsonArray(x: Value): x is JsonArray; /** * Cast a JSON value to `Array`, throwing a `JsonError` if the cast fails. * * @param x - JSON value to cast * @param prefix - optional error message prefix * @returns JsonArray * @throws {@link JsonError} if the cast fails * * @category Utilities: JSON */ export declare function asArray(x: Value, prefix?: string): JsonArray; /** * A more safely typed version of `JSON.parse()`. * * @param source - JSON string value to parse * @returns parsed JSON Value * * @category Utilities: JSON */ export declare function safeParse(source: string): Value; /** * A more safely typed version of `JSON.stringify()`. * * @param value - JSON value to stringify * @returns stringified JSON value * * @category Utilities: JSON */ export declare function safeStringify(value: Value): string; /** * Tests a JSON value to determine if it contains data. * * @remarks * The FHIR specification provides requirements on how to represent FHIR data in JSON. * These requirements are stricter than the JSON specifications. For our purposes, the * following requirements must guide our implementations for how JSON values are handled: * - Objects are never empty (implies arrays are also never empty). If an element is * present in the resource, it SHALL have properties as defined for its type, or 1 or * more extensions. * - String property values can never be empty. Either the property is absent, or it is * present with at least one character of content. * - The FHIR types `integer`, `unsignedInt`, `positiveInt` and `decimal` are represented * as a JSON number, the FHIR type `boolean` as a JSON boolean, and all other types * (including `integer64`) are represented as a JSON string which has the same content * as that specified for the relevant datatype. Whitespace is always significant * (i.e., no leading and trailing spaces for non-strings). * * @param x - JSON Value * @returns true if argument has actual data; false otherwise * * @see [JSON Representation of Resources](https://hl7.org/fhir/json.html) * @category Utilities: JSON */ export declare function hasFhirData(x: Value | undefined): boolean; //# sourceMappingURL=json-helpers.d.ts.map