Select Page

How to decode a JSON string using JavaScript

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.


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

Related Articles

Last Updated On March 20, 2018

Leave a reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.