Ejemplo json
let Settings = { "Policy": { "allowP": true, "allowC": false, } }¿Cómo puedo acceder a obtener valor usando la siguiente sintaxis?
console.log( Policy.allowP ); // should return true console.log( Policy.value.allowP ); // should also return trueTraté de seguir usando el proxy de javascript
let createProxy = (settings : any) => { const p = new Proxy(settings, { get(target, p, _r) { debugger; if (p === "value") { return settings; } return (target as any)[p]; }, }); return p; } let getSettings = () => { var settings = Settings; const p = new Proxy(settings, { get(target, p, _r) { debugger; if (p === "value") { return createProxy(settings); } return createProxy((target as any)[p]); }, }); return p; };Intenté crear un proxy anidado para poder acceder a los valores usando la sintaxis key.value.
¿Es esta la forma correcta de implementarlo? o hay alguna manera mejor?