1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Implemented 'strict' json support

This commit is contained in:
Ivan Savenko
2024-02-13 18:08:35 +02:00
parent d1c274f93f
commit 41493d6f67
8 changed files with 69 additions and 13 deletions

View File

@@ -17,10 +17,23 @@ class JsonNode;
using JsonMap = std::map<std::string, JsonNode>;
using JsonVector = std::vector<JsonNode>;
struct Bonus;
class CSelector;
class CAddInfo;
class ILimiter;
struct JsonParsingSettings
{
enum class JsonFormatMode
{
JSON, // strict implementation of json format
JSONC, // json format that also allows comments that start from '//'
//JSON5 // TODO?
};
JsonFormatMode mode = JsonFormatMode::JSONC;
/// Maximum depth of elements
uint32_t maxDepth = 30;
/// If set to true, parser will throw on any encountered error
bool strict = false;
};
class DLL_LINKAGE JsonNode
{
@@ -58,6 +71,7 @@ public:
/// Create tree from Json-formatted input
explicit JsonNode(const std::byte * data, size_t datasize);
explicit JsonNode(const std::byte * data, size_t datasize, const JsonParsingSettings & parserSettings);
/// Create tree from JSON file
explicit JsonNode(const JsonPath & fileURI);