Last Updated: February 25, 2016
·
454
· gsroberts

Something to know about .Net's Javascript serializer

.Net's javascript serializer creates a JSON object that relies on the use of eval() to determine data types once parsed. Running values through eval() can have unexpected results if you are working with a hyphenated value such as an ID that is comprised of parts of the year and a number, for instance, as eval() will try to perform the operation it detects. 13-5345 becomes -5332 once eval() is used in this way and likewise 2013-3-456 becomes 1554.

In the event that you must pass values such as these (or any value that may be interpreted as a math operation) through the javascript serializer in .Net, you can (and should) wrap the value in a two sets of quotes which will cause eval() to treat the value as a string.

Refer to:
Javascript eval() function reference @ w3schools.com Link