Reading information from JSON file

I’m looking to read information from a JSON file and I’m really struggling to find any understandable documentation/tutorial on this.

I’ve created a JSON with (for example)

“Item”: 1,
“Asset No”: 3671,
“Serial No”: “D20506279011451200250”,
“Manufacturer”: “AC Centre”,
“Model”: “KYR-250/X1C-M”
“Item”: 2,
“Asset No”: 3672,
“Serial No”: “D205069810114606200743”,
“Manufacturer”: “AC Centre”,
“Model”: “KYR-250/X1C-M”
}, etc…

I’ve installed the JSON Resource Loader too. There seems to be nothing that actually tells/shows me how to get to that information. I’ve trawled the forum and there’s nothing that helps (a lot of assumed knowledge stuff).


Unfortunately, JSON isn’t a format that has specific structured in every document, just a format that allows you or the author to provide structure using the same syntax.

Basically, every json document can have a completely different layout than each other. Because of this, there is nothing out of the box that is going to simplify this for you, and it is less assumed knowledge and more a “this is your json document and you are going to have to figure out what works best for you” situation.

You will either need to build out a set of events that parses each paramenter in your json into data that is usable (likely with the “string find” expressions and a bunch of math), you could also try to reformat the data in your json manually to make it match the structured variable format, then import that as a json directly into a variable (using the Load Json into variable actions), but in both cases you as the author (or user) of that json document would have to build out the logic specific to your use case.

Edit: if you would like to match the structured variable format, build out your desired structure variable first, thrn set up an event that writes a file to a location of your choosing using the write text file action, with the body being set to ToJSON(YourVariableHere). Running a preview will make it create that file with the structure in it)

How would I, for instance, get the text stored under “Asset No” (in this instance 3671)? All I need is something I can figure it out from!!

My recommendation would be to restructuring your json to follow the atructure variable format, then just import it into a structure scene or global variable, and then you can just call the variable. Again, I’d say build out a test structure variable in the format you want first, then convert that to json and then export that to text. This will give you a basic framework format to work from.

Otherwise you will need to build out your own method as mentioned, using the Find in String expression and either math or exact verbiage.

Could someone show me an example of how to get the information from, say, Item 2 displayed as text?

The JSON file is saved as “NDDH.json” in the same directory as the game file.

I’ve been told it can be done! I’ve trawled the forum, internet and ChatGPT with no real help. If I can get a working example I can figure it from there (it’s kind of how I learned GDevelop as a whole).

"Equipment": [
  "Item": 1,
  "Asset No": 1111,
  "Serial No": "A1234567890",
  "Manufacturer": "AC Centre 1",
  "Model": "KYR-111\/X1C-M"
  "Item": 2,
  "Asset No": 2222,
  "Serial No": "B1234567890",
  "Manufacturer": "AC Centre 2",
  "Model": "KYR-222\/X1C-M"
  "Item": 3,
  "Asset No": 3333,
  "Serial No": "C1234567890",
  "Manufacturer": "AC Centre 3",
  "Model": "KYR-333\/X1C-M"