generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Converting table to string

Previous Thread :: Next Thread 
ThrownException is not online. ThrownException
Joined: 17 Apr 2009
Total Posts: 1945
02 Nov 2015 12:08 AM
How would I convert a table to a string?
Report Abuse
Cryptize is not online. 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 is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
02 Nov 2015 12:14 AM
unpack does nothing of the sort.

table.concat
Report Abuse
ThrownException is not online. ThrownException
Joined: 17 Apr 2009
Total Posts: 1945
02 Nov 2015 12:16 AM
Does nothing for some reason.

Trying to convert game:GetService("HttpService").JSONDecode to string.
Report Abuse
Cryptize is not online. 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 is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
02 Nov 2015 12:18 AM
OP what kind of table do you have?
Report Abuse
ThrownException is not online. ThrownException
Joined: 17 Apr 2009
Total Posts: 1945
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 is not online. 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
ThrownException is not online. ThrownException
Joined: 17 Apr 2009
Total Posts: 1945
02 Nov 2015 12:31 AM
Is it possible to convert it into a string though?
Report Abuse
morashsPeasant is not online. morashsPeasant
Joined: 06 Jan 2011
Total Posts: 4944
02 Nov 2015 12:34 AM
Yes, like cntkillme said

JSONEncode the table

game.HttpService:JSONEncode(yourTable)
Report Abuse
ThrownException is not online. ThrownException
Joined: 17 Apr 2009
Total Posts: 1945
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 is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
02 Nov 2015 12:49 AM
Okay, then just JSONEncode that table -.-
Report Abuse
ThrownException is not online. ThrownException
Joined: 17 Apr 2009
Total Posts: 1945
02 Nov 2015 12:54 AM
But I need the json to be in regular text not in json form.
Report Abuse
ThrownException is not online. ThrownException
Joined: 17 Apr 2009
Total Posts: 1945
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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image