Michael Pidde => { Programmer(); }

JsonSmash

In light of not using Lua for actual scripting, only as a map file format, I've surgically removed Lua from my game and replaced it with JSON using the JSON for Modern C++ library. This doubles both as a very easy to consume data structure for my C++ engine code as well as a native object structure for my map editor which is browser based. Sure, I could waste the time building an editor as a desktop program, but there's little point to that when I was able to throw something together in HTML and JS much faster.

For the sake of obfuscation, even though I don't expect anyone to actually play my game, much less muck around with the files, I'm storing the map JSON as CBOR. This also has the benefit of slimming down the file size which is always desirable to me. It's quite simple to write a script to convert it back to a JSON string, but for random people poking around at game files, it won't be readily recognizable as a particular format other than a binary blob. In fact, I wrote a small program to convert JSON to CBOR and vice versa that my game build process can leverage to convert the map assets with.

Usage involves 3 arguments:

jsonsmash.exe 
    --intype json 
    --infile Q:\assets\maps\main.json 
    --outfile Q:\assets\maps\main.cbor

Intype can be changed to cbor and the Infile and Outfile targets swapped to convert from CBOR to JSON.

I've done a minor bit of input checking, but since I intend that I'll be the only person using this utility, stupid input will surely throw errors and crash the program. But if anyone's interested, here's a download: jsonsmash.zip