Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
Create Proxy for accessing json object values using .value

Example Json

  let Settings = {    
      "Policy": {        
          "allowP": true,
          "allowC": false,            
      }
  }

How can i access get value using following syntax

console.log( Policy.allowP ); // should return true
console.log( Policy.value.allowP ); // should also return true 

i tried following using javascript proxy

 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;
};

Tried to create Nested proxy so that i can access values using key.value syntax.

Is this correct way to implement it ? or is there any better way ?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!