Skip to content
Dannode36 edited this page Jul 16, 2025 · 5 revisions

Basic Usage

json2x can be run from the command line with arguments or as a standalone executable in shell mode (REPL. The basic syntax for conversion is:

<path to JSON file> <language to convert to> <optional args> e.g. C:\Users\json2x\Documents\coolData.json cpp

This is all you need to begin converting your JSON data into code but there is more json2x can do...

Optional Arguments

Usage Explanation
-f Force json2x to output code regardless of possibly fatal errors
-p Throw an error if placeholders are present after code generation. Requires the output to be perfect
-l Some extra logging for debugging and nerds
-i <type> <num> The indent used for code generation (currently only supports "space" and "tab")
-o <directory> Custom output directory. The default is the working directory

The help command is available in either execution mode to display the above information

Custom Formats

These are available for download alongside each release

Template format

{
  "int32": "",
  "uint32": "",
  "int64": "",
  "uint64": "",
  "float32": "",
  "float64": "",
  "bool": "",
  "string": "",
  "placeholder": "",
  "var": "",
  "array": "",
  "structStart": "",
  "structEnd": "",
  "usings": {
    
  },
  "extension": ""
}

C++ example

{
  "int32": "int",
  "uint32": "uint",
  "int64": "int64_t",
  "uint64": "uint64_t",
  "float32": "float",
  "float64": "double",
  "bool": "bool",
  "string": "string",
  "placeholder": "void*",
  "var": "{0} {1};",
  "array": "std::vector<{}>",
  "structStart": "struct {} {{",
  "structEnd": "};",
  "usings": {
    "std::string": "#include <string>",
    "std::vector": "#include <vector>"
  },
  "extension": "h"
}
Clone this wiki locally