Best way to create Objects out of this:


#1

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?

EDIT:
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 'https://www.nsbasic.com/i/ReadFile/datafile.js', which calls processData() to update the textbox below."
  Textarea1.value="" 
End function

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


#2

Does this function help?

http://wiki.nsbasic.com/JSON.Stringify

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


#3

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