Wednesday, September 10, 2014

jQuery convert a variable or string into a JSON object

I came across an example where I was given JSON data (custom object array) as a string in C# code behind. I then made it available to the front end jQuery/angularJs where it would need to be accessed as an object (to allow iteration).

The following line of jQuery will convert the variable into a JSON object which can then be used as such.

jQuery.parseJSON(myString);

No comments:

Post a Comment