MCPcopy Index your code
hub / github.com/VSCodeVim/Vim / fromJSObj

Method fromJSObj

src/vimscript/expression/evaluate.ts:1278–1295  ·  view source on GitHub ↗
(x: any)

Source from the content-addressed store, hash-verified

1276 }
1277 case 'json_decode': {
1278 const fromJSObj = (x: any): Value => {
1279 if (Array.isArray(x)) {
1280 return list(x.map(fromJSObj));
1281 } else if (typeof x === 'number') {
1282 return isInteger(x) ? int(x) : float(x);
1283 } else if (typeof x === 'string') {
1284 return str(x);
1285 } else {
1286 const items: Map<string, Value> = new Map();
1287 for (const key in x) {
1288 if (Object.hasOwnProperty.call(x, key)) {
1289 // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1290 items.set(key, fromJSObj(x[key]));
1291 }
1292 }
1293 return dictionary(items);
1294 }
1295 };
1296 const [expr] = getArgs(1);
1297 return fromJSObj(JSON.parse(toString(expr!)));
1298 }

Callers

nothing calls this directly

Calls 5

listFunction · 0.90
intFunction · 0.90
floatFunction · 0.90
strFunction · 0.90
dictionaryFunction · 0.90

Tested by

no test coverage detected