The object to process
Configuration options for parsing
The object with all JSON strings parsed
const input = {
data: '{"nested": "{\\"deeply\\": \\"nested\\"}"}',
payload: '{"foo": "bar"}',
someOtherProp: '["a", "b", "c"]'
};
const output = ParseJSONRecursive(input);
// Returns: {
// data: { nested: { deeply: "nested" } },
// payload: { foo: "bar" },
// someOtherProp: ["a", "b", "c"]
// }
with options
const input = {
content: 'Action results:\n[{"action": "test"}]'
};
const output = ParseJSONRecursive(input, { extractInlineJson: true, maxDepth: 50 });
// Returns: {
// content: "Action results:",
// content_: [{ action: "test" }]
// }
Recursively parse JSON strings within an object/array structure. This function will traverse through objects and arrays, attempting to parse any string values as JSON. If parsing succeeds, it continues recursively. This is particularly useful for handling deeply nested JSON structures where JSON is stored as strings within other JSON objects.
The function makes no assumptions about property names - it will attempt to parse any string value it encounters, regardless of the key name.