Toolbox-XToolbox-X

Parse Object Values

Recursively converts stringified primitive values within objects and arrays to their proper types (boolean, number, null, etc.).

parseObjectValues

The parseObjectValues function recursively scans an object or array and converts stringified primitive values (e.g., "true", "42", "null", "undefined") or valid JSON strings into their actual JavaScript types.

Function Signature

function parseObjectValues<T>(object: T, parseNested?: boolean): { [K in keyof T]: any }

Parameters

  • object (T): The object or array containing stringified values to parse.
  • parseNested (boolean, optional): Whether to recursively parse nested objects or arrays. Defaults to true.

Return Value

  • { [K in keyof T]: any }: A new object with parsed values.

Example Usage

playground.ts

Conversion Rules

  • "true" ==> true
  • "false" ==> false
  • "null" ==> null
  • "undefined" ==> undefined
  • Numeric strings (e.g. "42") ==> 42
  • JSON strings (e.g. '{"a":1}') ==> { a: 1 }

Aliases

The following aliases can be used for the parseObjectValues function:

  • parseStringifiedObjectValues

Last updated: Sun, Jun 14, 2026 07:52:00PM (UTC)

On this page