[ANN] libJson

David Bovill david.bovill at gmail.com
Wed Jan 7 17:13:54 EST 2009


This was just a quick hack - but it did seem to have worked for a while ( i
used it for putting arrays inside arrays and storing them as text files -
started with XML and then thought the better of it :), but I'm sure there
are loads of things it doesn't work with unicode?, certainly not the new
multidimensional arrays...

I'm posting it more to find out a bit more about why the urlEncode seemed to
work where all else failed :)

function array_Marshal someArray
    put keys(someArray) into someKeys
    put empty into baseTable
    repeat for each line someKey in someKeys
        put someArray[someKey] into someValue
        put urlencode(someValue) into encodedData
        -- put base64Encode(someValue) into encodedData
        -- replace return with empty in encodedData
        put someKey & tab & encodedData & return after baseTable
    end repeat
    delete last char of baseTable
    return baseTable
end array_Marshal

function array_UnMarshal baseTable
    set the itemdelimiter to tab
    repeat for each line someLine in baseTable
        put item 1 of someLine into someKey
        put item 2 of someLine into encodedData
        put urldecode(encodedData) into someValue
        -- put base64Decode(encodedData) into someValue
        put someValue into someArray[someKey]
    end repeat
    return someArray
end array_UnMarshal



More information about the use-livecode mailing list