Decodes a string of key-value pairs from data
and returns a comma separated string of keys and values. Note that keys will be in the even positions and values in the odd positions, such that if is the index of a key, its corresponding value will be at index in the resulting string.
When the function is called with:
wasKeyValueToCSV("position=<1,1,0>&toggle=on");
it will return the string:
"position", "<1,1,0>", "toggle", "on"
/////////////////////////////////////////////////////////////////////////// // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 // /////////////////////////////////////////////////////////////////////////// string wasKeyValueToCSV(string data) { return llList2CSV(llParseString2List(data, ["&", "="], [])); }
/////////////////////////////////////////////////////////////////////////// // Copyright (C) 2014 Wizardry and Steamworks - License: CC BY 2.0 // /////////////////////////////////////////////////////////////////////////// /// <summary> /// Serialises key-value tuples from data to comma-separated values. /// </summary> /// <param name="data">the data containing key-value pairs</param> /// <returns>a comma-separated string</returns> private static string wasKeyValueToCSV (string data) { return string.Join (",", data.Split ('&') .Select (p => p.Split ('=')).SelectMany (p => p) .ToArray ()); }