The real problem here, given the latest update to your question, is that the lat and lng values in your JSON data are strings instead of numbers.
In other words, where your JSON data looks like this (whitespace added for clarity):
[
{ "lat": "42.021631", "lng": "-93.624239" },
{ "lat": "19.112049", "lng": "72.870234" }
]
it should look like this:
[
{ "lat": 42.021631, "lng": -93.624239 },
{ "lat": 19.112049, "lng": 72.870234 }
]
The best way to fix this is to change your server code to generate that second format instead of the first one. I can't give specifics because I don't know what server language or libraries you are using. But if you can get the server to generate the lat and lng values as the numbers they should be instead of strings, everything will get easier.
If that can't be done, the solution is not to be mucking around with the JSON text, stripping out quotes or adding them back in with regular expressions. That is just creating a mess that you don't need and doesn't help you.
Instead, simply convert the lat and lng values to numbers where you need to.
For example, if you have the first element of your JSON array in a variable called location, you may be trying to create a LatLng object from it like this:
var latlng = new google.maps.LatLng( location.lat, location.lng );
That may not work, because location.lat and location.lng are strings, not numbers. But you can easily convert them to numbers:
var latlng = new google.maps.LatLng( +location.lat, +location.lng );
There are several ways to convert a string to a number, but the unary + operator is the most succinct.
How does the + operator work? It isn't specific to Google Maps or the LatLng object or anything like that. It's simply a JavaScript operator. If you apply the + operator to something that is already a number, it just leaves it alone. But if you apply + to a string, it converts it to a number.
Alternatively, you could use the parseFloat function:
var latlng = new google.maps.LatLng(
parseFloat(location.lat),
parseFloat(location.lng)
);
There's nothing wrong with that if you find it more clear, but try the + operator: once you get used to it, you may find you like it.
Again, though, the best solution is to fix the server code to generate proper JSON numbers as illustrated above.
JSON.parseconverts a JSON string to a javascript object