converting things to strings so they can be saved as projectdata or localdata

how does one convert a table, which in the specific axample i am looking at is a table of loaded images, into a string so that it can be saved as projectdata, and then back again so it can be loaded and used?

I’ll give you an example of how I did it in my project.

function splitAndSaveKMFilters()

local kmFiltersListString = ""
if kmFiltersList ~= nil then
    for i,v in ipairs(kmFiltersList) do
        kmFiltersListString = kmFiltersListString..v..","
    end
end
saveLocalData("kmFiltersList",kmFiltersListString)

end

function splitAndRestoreKMFilters()

local kmFiltersListString=readLocalData("kmFiltersList",kmFiltersList)
if type(kmFiltersListString) ~= "table" then
    for regionName in string.gmatch(kmFiltersListString,"[%a+%s%-]+") do
        table.insert(kmFiltersList,regionName)
    end
end

end

Now this only works if its more of a list as opposed to an array of data. But from here, you can get an idea on how to change it for other values other than straight strings from a table.

Easiest is to use a json library. It will convert a table to a string, and decode a table from a strnig. Here’s what I’m using and works well: http://www.chipmunkav.com/downloads/Json.lua

Hey @ruilov, that is a great library, it even worked on long nested tables out of the box.