|
| 02 Nov 2015 12:08 AM |
| How would I convert a table to a string? |
|
|
| Report Abuse |
|
|
Cryptize
|
  |
| Joined: 01 Oct 2010 |
| Total Posts: 949 |
|
|
| 02 Nov 2015 12:11 AM |
| http://wiki.roblox.com/index.php?title=Function_dump/Basic_functions#unpack |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Nov 2015 12:14 AM |
unpack does nothing of the sort.
table.concat |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2015 12:16 AM |
Does nothing for some reason.
Trying to convert game:GetService("HttpService").JSONDecode to string. |
|
|
| Report Abuse |
|
|
Cryptize
|
  |
| Joined: 01 Oct 2010 |
| Total Posts: 949 |
|
|
| 02 Nov 2015 12:18 AM |
| Do table.concat like cntkillme said, I forgot it existed lmao |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Nov 2015 12:18 AM |
| OP what kind of table do you have? |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2015 12:20 AM |
A server returns a string like so:
{"AssetId":1337,"AssetVersionId":1227}
and using JSONDecode makes this a table.
I am trying to convert the table to a string, if thats possible |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Nov 2015 12:26 AM |
JSONEncode will convert a table into a JSON string JSONDecode will convert a JSON string into a table |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2015 12:31 AM |
| Is it possible to convert it into a string though? |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2015 12:34 AM |
Yes, like cntkillme said
JSONEncode the table
game.HttpService:JSONEncode(yourTable) |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2015 12:47 AM |
| No, I need the table that JSONDecode returns to be converted to a string, not the other way around. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Nov 2015 12:49 AM |
| Okay, then just JSONEncode that table -.- |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2015 12:54 AM |
| But I need the json to be in regular text not in json form. |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2015 12:57 AM |
I need to to be from:
{"AssetId":1337,"AssetVersionId":1227}
to:
AssetId 1337 AssetVersionId 1227
in string form |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Nov 2015 01:38 AM |
| It is already a string. You just want to convert that to remove colons and quotes and braces then. Well it that case it's better to not JSONEncode it at all (JSONDecode it if it already is JSON'd) and iterate over the table. |
|
|
| Report Abuse |
|
|
AlgyLacey
|
  |
| Joined: 14 Jun 2013 |
| Total Posts: 3736 |
|
|
| 02 Nov 2015 04:41 AM |
function TableToString(Table) local String = "" for i,v in pairs (Table) do String = String.." "..i.." "..v end return String end
#code local First, Second, Third = "Create", "Publish", "Improve" |
|
|
| Report Abuse |
|
|