Class: JSONUtils ​
Defined in: packages/common/src/utils/json.ts:16
Utilities for working with JSON data.
Name ​
JSONUtils JSONUtils
Constructors ​
Constructor ​
new JSONUtils():
JSONUtils
Returns ​
JSONUtils
Methods ​
clone() ​
staticclone<T>(value):T
Defined in: packages/common/src/utils/json.ts:77
Deep clone a JSON value.
Type Parameters ​
T ​
T
Parameters ​
value ​
T
The JSON value to clone.
Returns ​
T
The cloned JSON value.
cloneInternal() ​
staticcloneInternal<T>(value,options?,seen?,depth?):any
Defined in: packages/common/src/utils/json.ts:259
Internal function to clone JSON values with options.
Type Parameters ​
T ​
T
Parameters ​
value ​
T
The value to clone.
options? ​
CloneOptions = {}
The cloning options.
seen? ​
WeakMap<object, any> = ...
A WeakMap to track seen objects for circular reference detection.
depth? ​
number = 0
Returns ​
any
The cloned value.
cloneReplace() ​
staticcloneReplace<T>(value,pattern,replacement):T
Defined in: packages/common/src/utils/json.ts:91
Deep clone a JSON value, replacing strings that match a pattern.
Type Parameters ​
T ​
T
Parameters ​
value ​
T
The JSON value to clone.
pattern ​
RegExp
The regex pattern to match strings.
replacement ​
string
The replacement string.
Returns ​
T
The cloned JSON value with replacements.
copy() ​
staticcopy<T>(value):T
Defined in: packages/common/src/utils/json.ts:68
Shallow copy of a JSON object.
Type Parameters ​
T ​
T extends JsonObject
Parameters ​
value ​
T
The JSON object to copy.
Returns ​
T
The copied JSON object.
deepEqual() ​
staticdeepEqual(a,b,seen?,depth?):boolean
Defined in: packages/common/src/utils/json.ts:106
Deep equality check between two values.
Parameters ​
a ​
unknown
The first value to compare.
b ​
unknown
The second value to compare.
seen? ​
WeakMap<object, object> = ...
A WeakMap to track seen object pairs for circular reference detection.
depth? ​
number = 0
Returns ​
boolean
True if the values are deeply equal.
deleteKeys() ​
staticdeleteKeys<T>(value,keys):T
Defined in: packages/common/src/utils/json.ts:201
Delete specified keys from a JSON value.
Type Parameters ​
T ​
T
Parameters ​
value ​
T
The JSON value to process.
keys ​
(string | number | symbol)[]
The keys to delete.
Returns ​
T
The JSON value with specified keys deleted.
isObject() ​
staticisObject(value):value is JsonObject
Defined in: packages/common/src/utils/json.ts:22
Check if a value is a JSON object (not an array, not null, and has Object prototype).
Parameters ​
value ​
unknown
The value to check.
Returns ​
value is JsonObject
True if the value is a JSON object.
isParsable() ​
staticisParsable(value):value is string
Defined in: packages/common/src/utils/json.ts:34
Check if a value is a parsable JSON string.
Parameters ​
value ​
unknown
The value to check.
Returns ​
value is string
True if the value is a parsable JSON string.
isUnprototyped() ​
staticisUnprototyped(value):value is JsonObject
Defined in: packages/common/src/utils/json.ts:49
Check if a value is an unprototyped object (i.e., Object.create(null)).
Parameters ​
value ​
unknown
The value to check.
Returns ​
value is JsonObject
True if the value is an unprototyped object.
normalize() ​
staticnormalize<T>(value):JsonObject
Defined in: packages/common/src/utils/json.ts:59
Normalize a JSON value by stripping prototypes from all objects within it.
Type Parameters ​
T ​
T extends any[] | JsonObject
Parameters ​
value ​
T
The JSON value to normalize.
Returns ​
The normalized JSON value.
sanitize() ​
staticsanitize<T>(value):T
Defined in: packages/common/src/utils/json.ts:229
Sanitize a JSON value by removing undefined values from objects and arrays.
Type Parameters ​
T ​
T
Parameters ​
value ​
T
The JSON value to sanitize.
Returns ​
T
The sanitized JSON value.