JSON manipulation utilities for nested i18n structures. Handles flattening, unflattening, deep merging, and ICU message detection.

Methods

(inner) flattenJson(obj, prefixopt, resultopt) → {Record.<string, string>}

Flattens nested JSON to dot-notation keys

Parameters:
NameTypeAttributesDefaultDescription
objObject
prefixstring<optional>
''
resultObject<optional>
{}
Returns:
Type: 
Record.<string, string>
Example
flattenJson({ user: { name: 'John' } }) // { 'user.name': 'John' }

(inner) isICUMessage(value) → {boolean}

Detects ICU MessageFormat syntax (plural, select, selectordinal)

Parameters:
NameTypeDescription
value*
Returns:
Type: 
boolean

(inner) mergeDeep(target, source) → {Object}

Deep merges source into target, preserving existing values

Parameters:
NameTypeDescription
targetObject
sourceObject
Returns:
Type: 
Object

(async, inner) readJsonFile(filePath, verboseopt) → {Promise.<(Object|null)>}

Parameters:
NameTypeAttributesDefaultDescription
filePathstring
verboseboolean<optional>
false
Returns:
Type: 
Promise.<(Object|null)>

(inner) readJsonFileSync(filePath, verboseopt) → {Object|null}

Parameters:
NameTypeAttributesDefaultDescription
filePathstring
verboseboolean<optional>
false
Returns:
Type: 
Object | null

(inner) unflattenJson(obj) → {Object}

Restores nested structure from dot-notation keys

Parameters:
NameTypeDescription
objRecord.<string, string>
Returns:
Type: 
Object
Example
unflattenJson({ 'user.name': 'John' }) // { user: { name: 'John' } }

(async, inner) writeJsonFile(filePath, data) → {Promise.<void>}

Parameters:
NameTypeDescription
filePathstring
dataObject
Returns:
Type: 
Promise.<void>