How to decode a JSON string using JavaScript

No Comments

If you have a JSON encoded string that you might have received from a ajax scriptand you need to decode it using JavaScript you can use the eval() function to decode the string. The eval() function evaluates or executes an given argument.

Example:

var string = '{"id" : 32}'; 
var d = eval('(' + string + ')'); 
alert(d.id); //will alert 32

Image Credits: Photo by Isis França on Unsplash.

Related Articles

No results found

Leave a Reply

avatar
  Subscribe  
Notify of
Menu
Copy link