javascript tutorial - [Solved-5 Solutions] Safely turning a JSON string into an object - javascript - java script - javascript array
Problem :
How to Safely turning a JSON string into an object ?
Solution 1:
can do this unsafely with something like
but that leaves us vulnerable to the json string containing other code, which it seems very dangerous to simply eval.
Solution 2:
Is a pure JavaScript approach so long as you can require a reasonably modern browser.
Solution 3:
The jQuery method is now deprecated. Use this method instead:
Solution 4:
Use simple code represented in the following link on MSDN .
and reverse
Solution 5:
Calling evalJSON() with true as the argument sanitizes the incoming string.