UUID and JSON - SELECT SQL

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Post Reply
heroumi
Posts: 63
Joined: 28 May 2023, 13:18

UUID and JSON - SELECT SQL

Post by heroumi »

Hello,
Does SFS2x server-side support retrieving data: UUID and JSON from database?
I tried many times but it didn't work. My database is Postgres.
Thank you.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: UUID and JSON - SELECT SQL

Post by Lapo »

Hi,
a UUID or JSON are essentially text, if you store them as such in the DB there should be no problems.

If you're expecting these objects to translate to specific Java objects auto-magically then the answer is no, but you can always query the database directly via JDBC.
Take a look here, for instance:
https://smartfoxserver.com/blog/using-a ... st-part-3/

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
heroumi
Posts: 63
Joined: 28 May 2023, 13:18

Re: UUID and JSON - SELECT SQL

Post by heroumi »

Lapo wrote:Hi,
a UUID or JSON are essentially text, if you store them as such in the DB there should be no problems.

If you're expecting these objects to translate to specific Java objects auto-magically then the answer is no, but you can always query the database directly via JDBC.
Take a look here, for instance:
https://smartfoxserver.com/blog/using-a ... st-part-3/

Cheers


Hi,
I used: postgresql-42.7.1 and "lac" login assistant. But it can't get json or uuid data. especially I'm interested in uuid. Because some 3rd party authentication providers use UUID as an id for the user.
Did I miss anything? or the login assistant does not support UUID for username and nickname.
Thank
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: UUID and JSON - SELECT SQL

Post by Lapo »

If this UUID is stored as a String I see no problem in using it. Otherwise if it uses some kind of DB-specific type it can be a problem, because our API only support a subset of types that are common among different DBs.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
heroumi
Posts: 63
Joined: 28 May 2023, 13:18

Re: UUID and JSON - SELECT SQL

Post by heroumi »

Lapo wrote:If this UUID is stored as a String I see no problem in using it. Otherwise if it uses some kind of DB-specific type it can be a problem, because our API only support a subset of types that are common among different DBs.

Cheers

Hi,
I want to talk about UUID format in database.
I tried several ways but couldn't read the "lac" Login Assistant test.
Void*
Posts: 96
Joined: 15 Feb 2021, 13:49

Re: UUID and JSON - SELECT SQL

Post by Void* »

To read UUID from Postgre, make the query as normal, then cast it from object out of the result set

Code: Select all

var myId = result.getObject("columnName", java.util.UUID.class);


JSON is just a string,

Code: Select all

var jsonString = result.getString("jsonColumnName");


If you're using org.json

Code: Select all

var jsonObj = new JSONObject(result.getString("jsonColumnName"));


then you can pull your json properties like normal

Code: Select all

var playerName = jsonObj.get("player_name");
for example.
Post Reply