Every line of 'javascript json decode' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
5 function decode(json) { 6 return JSON.parse(json); 7 }
Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code
39 static decode(obj: any) { 40 if (obj && obj.$type === 'ObjectId') { 41 return new MongoDb.ObjectID(obj.$value); 42 } 43 if (obj && obj.$type === "Date") { 44 return new Date(obj.$value); 45 } 46 if (obj && obj.$type === "RegExp") { 47 return new RegExp(obj.$value.$pattern, obj.$value.$flags); 48 } 49 if (Array.isArray(obj)) { 50 return [...obj.map(JsonEncoder.decode)]; 51 } 52 if (obj && typeof obj === 'object') { 53 for (const [key, value] of Object.entries(obj)) { 54 obj[key] = JsonEncoder.decode(value); 55 } 56 } 57 58 return obj; 59 }