Home Safely turning a JSON string into an object
Reply: 0

Safely turning a JSON string into an object

user363
1#
user363 Published in June 23, 2018, 4:25 am

Given a string of JSON data, how can you safely turn that string into a JavaScript object?

Obviously you can do this unsafely with something like...

var obj = eval("(" + json + ')');

...but that leaves us vulnerable to the json string containing other code, which it seems very dangerous to simply eval.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.597946 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO