How do I proccess data sent via Roblox Httpservice?

If I send data to an external database URL containing a table, how would I go to process that data on the database’s end? I am trying to connect Roblox to my Discord bot and I am having some issues. Do I decode the table that is sent or use it as is?

1 Like

Can you provide an example of data you want to send/receive?

If so:

Data = ["Hello"]

Decode it with JSONDecode, that’s easier.
You could also leave it encode if you are going to save it.

They want to save the data at external database which isn’t roblox datastore so they don’t need to encode it to save. Just encode if they want to get it to roblox from that external db.

Can save a string, right? An encoded table is technically a string.

Idk. You get data from db/website or smth as JSON and encode it to a table (table is like roblox alternative to json). Never tried encoding a table.

You can save strings, yeah but you probably can’t encode a table, because roblox marks table as encoded json.

For Roblox, an encode table is a string/text:

local T = {Name = "Bob",			Age = 36}
Data = game.HttpService:JSONEncode(T)
print(type(Data))		-- string	

So if the external DataStore can save text, the table should stay the same when it is returned, right?

Roblox detects JSON as a string. You can’t check type of encoded object in Roblox because it will be always a string which isn’t true for other languages.

Sorry for the delay.

I am using Axios to send Roblox tables to my Repl.it bot and then save it to repl.it’s datastore.

Repl.it’s database is NoSQL or SQL? Nvm found it

The confusion is the following:

do I manipulate the data sent as an ordinary javascript array or do I have to decode it in the IDE on replit?

You’re using the @replit/database npm package to manipulate the data?

I am mainly using it to store it there, but I need to know if the data that arrives is an array for example I send the following data from Roblox

local data = {"potato", true, "foo", 4256}

will the array that arrives in the JS script behave like this?

const sentData = ["potato", true, "foo", 4256]

In JS the data should look the same as the table in Lua so should be able to be directly saved to the database. Although you will have to try it and see if this will work, because I’m not 100% sure.

Ok, I will give it a try and check with you again if it doesn’t work.