Skip to content

[Discussion] JSON Formatting for files #1794

@BraedonWooding

Description

@BraedonWooding

Information

This is purely design, and doesn't contain the full document. Some of the names are capitalized (maybe incorrectly but again this is more the layout then specifics).

Structure?

The structure follows a more modern and cleaner json style, instead of an array of objects we just define it as a single object with the top level property names often being the 'type' or 'name' of the object, i.e.
{ "power_cable": {...} }. This means that iterating through every property which while is a little more work on our side, makes the modders job easier and makes documents actually readable. Every document is valid JSON also (obviously).

Examples

This

<?xml version="1.0" encoding="utf-8" ?>
<Inventories>
    <Inventory type="raw_iron" maxStackSize="50" basePrice="0.8" category="inv_cat_raw" localizationName="inv_raw_iron" localizationDesc="inv_raw_iron_desc"/>
    <Inventory type="ice" maxStackSize="10" basePrice="1.2" category="inv_cat_raw" localizationName="inv_ice" localizationDesc="inv_ice_desc"/>
    <Inventory type="raw_copper" maxStackSize="50" basePrice="0.8" category="inv_cat_raw" localizationName="inv_raw_copper" localizationDesc="inv_raw_copper_desc"/>
</Inventories>

To

{
	"raw_iron": {
		"MaxStackSize": 50,
		"BasePrice": 0.8,
		"Category": "inv_cat_raw",
		"LocalizationName": "inv_raw_iron",
		"LocalizationDesc": "inv_raw_iron_desc"
	},
	"ice": {
		"MaxStackSize": 10,
		"BasePrice": 1.2,
		"Category": "inv_cat_raw",
		"LocalizationName": "inv_ice",
		"LocalizationDesc": "inv_ice_desc"
	},
	"raw_copper": {
		"MaxStackSize": 50,
		"BasePrice": 0.8,
		"Category": "inv_cat_raw",
		"LocalizationName": "inv_raw_copper",
		"LocalizationDesc": "inv_raw_copper_desc"
	}
}

This

<?xml version="1.0" encoding="utf-8"?>
<Overlays>
    <Overlay type="oxygen" min="0" max="1" colorMap="Jet">oxygenValueAt</Overlay>
    <Overlay type="room" min="0" max="1" colorMap="Random">roomNumberValueAt</Overlay>
</Overlays>

To

{
	"oxygen": {
		"min": 0,
		"max": 1,
		"colorMap": "Jet",
		"functionName": "oxygenValueAt"
	},
	"room": {
		"min": 0,
		"max": 1,
		"colorMap": "Random",
		"functionName": "roomNumberAtValueAt"
	}
}

Files

Below are all the files. They are in .txt cause that is the only format that github allows for text.
Overlay.txt
PerformanceHUDTemplate.txt
Quest.txt
RoomBehavior.txt
SettingsTemplate.txt
SheduledEvents.txt
Ships.txt
Stats.txt
Tiles.txt
Trader.txt
Utility.txt
ConsoleCommands.txt
Currency.txt
Furniture.txt
GameEvents.txt
Headlines.txt
Inventory.txt
Need.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions