Best way to create Objects out of this:


I have a file on my website that contains just this content:

var addressPoints = [
[11.42944444, 103.51333333, "img1.jpg", "300", "168", "waterfall"],
[11.32611111, 103.52111111, "img2.jpg", "300", "168", "river"],
[11.26083333, 103.51916667, "img3.jpg", "300", "168", "top view"]

I am reading that file, adding (or later removing) an item/image and upload/update the file via ajax.

But I wonder what would be the cleanest way to convert that into js objects!?

Do I need to go through each line and split at the comma to get item[n] or is there any other way?

By accident I stumpled across this code in the Ajax ReadFile Example:

function btnGetRemoteData_onclick()
  'This is like GetLocalData above, except it executes a remote file.
  'What is interesting is that the file does not have to be on the
  'same server as the app was run from, which ReadFileRemote required.
  txtWhy.value="Execute remote file '', which calls processData() to update the textbox below."
End function

that’s awesome. So I can use the array directly integreated in my code!
MsgBox addressPoints[0]


Does this function help?

JSON.stringify converts an object to a string. The data is saved in JSON format, which is a widely used standard for exchanging data.


well, I have checked that before posting here. But I came to the conclusion that this doesn’t work. Maybe I should check again.