Asset - Scripts JSON Struct: Use structs and arrays to work with JSON


JSON Struct
Bringing out the true potential of JSON parsing in GMS 2.3+


This library allows encoding and decoding JSON as structs, arrays and other first-order data types as of GMS 2.3. In addition to encoding and decoding functions, it also contains utilities for encryption and saving/loading JSON files. With its concise syntax and comprehensively tested code base, JSON Struct will change the way you think about JSON handling in GML.

Downloads / Links
YoYo Marketplace: Link
GitHub: Link | Repository | Wiki


Post-2020 GML with JSON Struct:

json_data = {
  data: [
      name: "Alice"
      hp: 5
      name: "Bob",
      HP: 6
json = jsons_encode(json_data);
Pre-2020 stock GML
var json_data = ds_map_create();
var sublist = ds_list_create();
ds_map_add_list(json_data, "data", sublist);
ds_list_add(sublist, ds_map_create());
ds_map_add(sublist[| 0], "name", "Alice");
ds_map_add(sublist[| 0], "HP", 5);
ds_list_mark_as_map(sublist, 0);
ds_list_add(sublist, ds_map_create());
ds_map_add(sublist[| 1], "name", "Bob");
ds_map_add(sublist[| 1], "HP", 6);
ds_list_mark_as_map(sublist, 1);
var json = json_encode(json_data);

Feedback Welcome!
If you have any suggestions or bug reports, please open an issue or contribute on GitHub.
Last edited: