MCPcopy Create free account
hub / github.com/zxlie/FeHelper / deepParseJSONStrings

Function deepParseJSONStrings

apps/json-format/json-auto-utils.js:232–264  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

230 }
231
232 function deepParseJSONStrings(obj) {
233 if (Array.isArray(obj)) {
234 return obj.map((item) => {
235 if (typeof item === 'string' && item.trim()) {
236 try {
237 const parsed = parseWithBigInt(item);
238 if (isJSONContainer(parsed)) {
239 return deepParseJSONStrings(parsed);
240 }
241 } catch (_) {}
242 }
243 return deepParseJSONStrings(item);
244 });
245 }
246 if (typeof obj === 'object' && obj !== null) {
247 const newObj = {};
248 Object.keys(obj).forEach((key) => {
249 const value = obj[key];
250 if (typeof value === 'string' && value.trim()) {
251 try {
252 const parsed = parseWithBigInt(value);
253 if (isJSONContainer(parsed)) {
254 newObj[key] = deepParseJSONStrings(parsed);
255 return;
256 }
257 } catch (_) {}
258 }
259 newObj[key] = deepParseJSONStrings(value);
260 });
261 return newObj;
262 }
263 return obj;
264 }
265
266 function unpackTopLevelEscapedJSON(value) {
267 if (typeof value !== 'string' || !value.trim()) return value;

Callers 2

parseJSONLikeFunction · 0.70

Calls 2

isJSONContainerFunction · 0.85
parseWithBigIntFunction · 0.70

Tested by

no test coverage detected