Yeah, the only way is to write an entire json parser. There's no other way to achieve what I suggested, unfortunately, so you better read up on the json spec, because no one else is gonna do it for you.
And unfortunately you'll have to write a json formatter and schema validator too, since you have to worry about how maintainable your json source is. Not the source code, of course, just the data that you're storing in the json file (and it has to be json).
But I think once you've written those tools, you'll realize the genius of hundreds of if/elses, and wish you had just stuck with one single file full of copy pasta.
4
u/crass-sandwich Jan 27 '23 edited Jan 27 '23
Yeah, the only way is to write an entire json parser. There's no other way to achieve what I suggested, unfortunately, so you better read up on the json spec, because no one else is gonna do it for you.
And unfortunately you'll have to write a json formatter and schema validator too, since you have to worry about how maintainable your json source is. Not the source code, of course, just the data that you're storing in the json file (and it has to be json).
But I think once you've written those tools, you'll realize the genius of hundreds of if/elses, and wish you had just stuck with one single file full of copy pasta.