summaryrefslogtreecommitdiffstats
path: root/logic/minecraft/JarMod.cpp
blob: bf985707b35fb609269893de9c635f9dc243b68e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "JarMod.h"
#include "Json.h"
using namespace Json;

JarmodPtr Jarmod::fromJson(const QJsonObject &libObj, const QString &filename, const QString &originalName)
{
	JarmodPtr out(new Jarmod());
	if (!libObj.contains("name"))
	{
		throw JSONValidationError(filename +
								  "contains a jarmod that doesn't have a 'name' field");
	}
	out->name = libObj.value("name").toString();
	out->originalName = libObj.value("originalName").toString();
	return out;
}

QJsonObject Jarmod::toJson()
{
	QJsonObject out;
	writeString(out, "name", name);
	if(!originalName.isEmpty())
	{
		writeString(out, "originalName", originalName);
	}
	return out;
}