Structure to JSON

I was hoping to package up a structure and save it as a json text file to send to a server. If i use GlobalVariableToJSON() and save that to a variable, it creates the entire structure again and trying to send that file just sends [structure]. Is there a way to process a structure into a json that is a json of the content of the structure and not the structure itself? (did that make sense?)

How are you saving it to a variable? I would have thought the action to set variable string, and using the GlobalVarToJSON() output as the value should do it:

Kia kaha :slight_smile:

that’s what I thought. But the “SomeStringVariable” becomes a structure.

Why are you not just saving your text file with GlobalVarToJSON? Why are you saving it to another variable?

I want to send it to a server via mqtt. The structure is the game stats and the server would parse it into a leaderboard and compare performances of different players. Are you suggesting I save it as a text file then load that to send on? I thought the text file option was only valid on desktop apps.

Doh. I’m an idiot. I don’t know why i thought I needed to save it before sending.

This totally worked. Thanks!

1 Like

I would have sworn on a stack of books that I had tried that first and it didn’t work. There is something magical about posting to the forum where you suddenly see the mistakes you’ve been staring at for days. Thanks heaps!

1 Like

Hmm, you’re doing something wrong then - here’s what I get when from the debugger:

Anyway, it looks like the the gremlins of GDevelop have left you alone.