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

Function buildJSONLikeCandidates

apps/json-format/json-auto-utils.js:396–419  ·  view source on GitHub ↗
(source, options)

Source from the content-addressed store, hash-verified

394 }
395
396 function buildJSONLikeCandidates(source, options) {
397 options = options || {};
398 const candidates = [];
399 const seen = new Set();
400 const addCandidate = (value) => {
401 value = String(value || '').trim();
402 if (!value || seen.has(value)) return;
403 seen.add(value);
404 candidates.push(value);
405 };
406
407 const normalized = String(source || '').trim();
408 const stripped = stripJSONGuards(normalized);
409
410 addCandidate(normalized);
411 addCandidate(stripped);
412
413 if (options.allowExtractJSONFragment !== false && !/^[\{\[]/.test(stripped) && !(options.nestedEscapeParse && /^["']/.test(stripped))) {
414 addCandidate(extractBalancedJSONContainer(stripped));
415 addCandidate(extractBalancedJSONContainer(normalized));
416 }
417
418 return candidates;
419 }
420
421 function parseJSONLike(source, options) {
422 options = options || {};

Callers 1

parseJSONLikeFunction · 0.85

Calls 3

stripJSONGuardsFunction · 0.85
addCandidateFunction · 0.70

Tested by

no test coverage detected