I've been using JSON to store a lot of my game's data. I love it compared to my previous workflow. Having a human-readable hierarchy of arbitrary information is a godsend. My needs have grown more complicated, however, and this solution doesn't work as well anymore.

I need my data entries to be able to reference each other. I devised the convention that any string prefixed with an "@" character described a relative or absolute path to another point in the JSON document. This worked when it was simple, but any time major reorganization was required all those references broke.

How does on accomplish this task? I'd love an editor that could jump to referenced data, or allow values to be edited where they are referenced, and would auto-update all those references for me when I change how they're organized. Frankly, forms work better for simple data entry tasks than text editors built for code. But then, I also want to work in a file format that's not going to fray my nerves to have to parse later when I'm bringing the file into my game, which is why I've preferred formats like JSON and CSV that are human readable and relatively simply.

What are the best practices for this scenario?

Edit: Some more information as requested in the comments:

I’d hoped to make my data outside my coding environment using a more appropriate tool, then to import it into my final project as a resource that could be compiled into the executable. At runtime it functions as a resource to be read from, but not written to. The data is referred to by runtime procedures that treat it as patterns for generating objects based on random weighted parameters. The generated objects are given references to the data and other objects they need to function. Anything that needs to be created, changed, or deleted lives in something generated, not the original data. The data referenced needs a network topology so that objects referencing its nodes can traverse the data by following the edges between those nodes in search of what they need.

All the necessary data exists in one big object, with no outside links to, for instance, the internet. Although, I will be treating generated objects similar to objects in my dataset as they in turn can be generated from and referenced. I suspect I’ll be wanting to reuse whatever solution I devise for my data to serialize a game state of complex, linked, arbitrary and non-homogeneous generated objects to the users hard drive between play sessions.


1 Answer 1


Sounds like you need an SQL database. This allows you to reference other objects by keys. If you want it to be human readable you can build a system to save it to a text file or CSV yourself. Although if you're using a popular engine you might be able to find a prebuilt system that does something like this for you already.

  • \$\begingroup\$ "If you want it to be human readable you can build a system to save it to a text file or CSV yourself" — by my reading, the question seems to be asking how to do that. \$\endgroup\$
    – DMGregory
    Oct 27, 2021 at 19:15
  • \$\begingroup\$ I was looking at SQL and it's variants. Correct me if I'm wrong, but is this not more for linking a series of tables containing homogenous objects, sort of like a series of CSVs that can refer to each other, rather than arbitrary non-homogenous objects like JSON might encode? Or is their a standard way to organize objects through SQL to accomplish the latter? Also, how plausible will converting SQL to CSVs be? My understanding is that SQL could be rather complicated to have to parse myself. \$\endgroup\$
    – Lake
    Oct 27, 2021 at 23:44
  • \$\begingroup\$ Well if your objects are different that will obviously make things much more difficult. But you could probably store your SQL table as JSON. \$\endgroup\$
    – andrew zuo
    Oct 28, 2021 at 2:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .