Data Exporter to JSON


Outputs|Exports a JSON file to /script-output/recipe-lister that lists all recipes, crafting machines, mining drills, belts, inserters, resources, items, fluids, and technologies loaded on player creation. Settings for split files and toggles for each category

Utilities
3 years ago
0.16 - 1.1
773

b Output is not always valid JSON

3 years ago
(updated 3 years ago)

Hi - thanks for this mod! It has been a huge time saver when running calculations outside of the game.

I've found that some sections of the exported JSON contain invalid tokens. Specifically, they contain raw literals like inf and -inf. These occur in the output from the latest version (1.1.36) in two sections ("resource" and "tile"), in subsections related to "autoplace_specification". These sections seem to contain the serialized AST for Lua functions. In context, the invalid tokens look something like this:

{
  "type" : "literal-number",
  "literal_value" : -inf
}

Special float values like inf and NaN are not allowed by the JSON spec, so compliant parsers will choke on them. These infinities are legitimate values in the underlying Lua data, so the best fix is probably to encode them as strings:

{
  "type" : "literal-number",
  "literal_value" : "-inf"
}
3 years ago

Thanks for bringing this to my attention, I'll try implementing that fix.

3 years ago

Awesome, then I can also cleanup some data pre-processing.

New response