You need to use JSON.parse with the reviver parameter:
var jsonString = '[{"name":"eric","age":"24"},{"name":"goulding","age":"23"}]';
var reviver = function (key, value) {
var number = Number(value);
return number === number ? number : value;
};
var data = JSON.parse(jsonString, reviver);
When reviver is called with reviver("name", "eric"), it returns "eric"because it "eric"cannot be converted to a number. However, when called with reviver("age", "24"), the number is returned 24.
Meanwhile, as others have already noted, the literal [{"name":"eric","age":"24"},{"name":"goulding","age":"23"}]is not JSON, it is an array. But the string '[{"name":"eric","age":"24"},{"name":"goulding","age":"23"}]'is a valid array object in JSON format.