Quick question regarding obtaining only a specific part of the asset information from a link

Basically, how would I obtain a specific part of the information (such as the “VersionNumber” of a place) when I am using a script to obtain that info and it puts that specific info into a GUI? I hardly worked with this before, so I am a bit uncertain about this.

For example, if I was using https://api.roblox.com/assets/2140578234/versions (obtaining the info with HttpService from that API, already have this all figured out in a script btw) to get specifically the “VersionNumber” number and not any of the other info that comes up in that link, how would I accomplish this? I would want to only get the number “2” (which is just the VersionNumber) and not any of the other numbers/text, such as in:

[{"Id":2688078983,"AssetId":2140578234,"VersionNumber":2,"ParentAssetVersionId":2688078927,"CreatorType":1,"CreatorTargetId":23952489,"CreatingUniverseId":null,"Created":"2018-07-28T14:26:47.8182853-05:00","Updated":"2018-07-28T14:26:47.8182853-05:00"}]
(this example is from the link)

Thanks.

I think what you’re looking for is JSONDecode. It takes a JSON table, like the one in your example, and converts it into a table that you can use. Example:

local http = game:GetService("HttpService")
local result = somePostRequestHere
local tab = http:JSONDecode(result)
print(tab.VersionNumber) --> 2

Although you will need to create a proxy to do this, as you cannot directly send request to .roblox.com websites.

5 Likes

Thanks, can confirm this worked.