Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- util = LoadLibrary("RbxUtility")
- encode = util.EncodeJSON
- decode = util.DecodeJSON
- -- First, I'll create an example table & print its keys/values
- print(string.rep("-",80))
- exampleTable = {
- Description = "This is the description of the item";
- [2] = "This is the 2nd index on my table.";
- ["Text"] = 4;
- }
- print("Example Table Keys and Values:")
- print()
- for key,value in pairs(exampleTable) do
- print(tostring(key).." = "..tostring(value))
- end
- -- Now I'll convert this example into a JSON string and print it.
- print()
- print("JSON Version of the Example table:")
- print()
- local JSON_String = encode(exampleTable)
- print(JSON_String)
- -- Then reconvert it into a table & print its keys/values
- print()
- print("New Example Keys & Values:")
- print()
- local newExample = decode(JSON_String)
- for key,value in pairs(newExample) do
- print(tostring(key).." = "..tostring(value))
- end
- print(string.rep("-",80))
- -- You should get the same keys and values as you did when you started.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement