|
| 02 Nov 2015 05:02 PM |
How would I turn this string: {"AssetId":1337,"AssetVersionId":1227}
Into this: 1227
The AssetVersionId will become a bigger number over time. |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2015 05:19 PM |
| http://wiki.roblox.com/index.php?title=Function_dump/String_manipulation |
|
|
| Report Abuse |
|
|
Zaxerion
|
  |
| Joined: 09 Feb 2013 |
| Total Posts: 2304 |
|
|
| 02 Nov 2015 05:22 PM |
local string = "{"AssetId":1337,"AssetVersionId":1227}"
local function decode(str)
end
decode(string)
Theres a start, lol |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2015 07:33 PM |
Solved:
local r1 = "{"AssetId":1337,"AssetVersionId":1227}"
local r = 38 + string.len(string.sub(r1, 39)) print(string.sub(r1, 39, tonumber(r) - 1))
This makes it so that no matter how large the number, it will always output the correct numbers. |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 02 Nov 2015 07:37 PM |
local s = [[{"AssetId":1337,"AssetVersionId":1227}]] local ss = s:match("%d+}$") ss=ss:sub(1,#ss-1) print(ss)
Red Blossoms |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 02 Nov 2015 07:38 PM |
cleaner:
local s = [[{"AssetId":1337,"AssetVersionId":1227}]] local ss = s:gsub("}",""):match("%d+$") print(ss)
Red Blossoms |
|
|
| Report Abuse |
|
|
ash877
|
  |
| Joined: 18 Feb 2008 |
| Total Posts: 5142 |
|
|
| 02 Nov 2015 07:56 PM |
| why is everyone except for ray doing this wrong XD |
|
|
| Report Abuse |
|
|
| |
|
|
| 02 Nov 2015 08:07 PM |
| Why all this string matching fuss when this could be done easily with JSONEncode and JSONDecode.. |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2015 08:23 PM |
http://wiki.roblox.com/index.php?title=API:Class/HttpService/JSONEncode
It turns a string into JSON.
What I needed was it to be in non-JSON form.
I already solved it. |
|
|
| Report Abuse |
|
|
|
| 02 Nov 2015 08:25 PM |
| http://wiki.roblox.com/index.php?title=API:Class/HttpService/JSONDecode |
|
|
| Report Abuse |
|
|