2014-05-09 20:46:25 +05:30
|
|
|
#include "JarMod.h"
|
2015-05-28 23:08:29 +05:30
|
|
|
#include "Json.h"
|
|
|
|
using namespace Json;
|
2014-05-09 20:46:25 +05:30
|
|
|
|
2015-06-01 01:15:28 +05:30
|
|
|
JarmodPtr Jarmod::fromJson(const QJsonObject &libObj, const QString &filename, const QString &originalName)
|
2014-05-09 20:46:25 +05:30
|
|
|
{
|
|
|
|
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();
|
2015-06-01 01:15:28 +05:30
|
|
|
out->originalName = libObj.value("originalName").toString();
|
2014-05-09 20:46:25 +05:30
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2014-05-11 16:07:21 +05:30
|
|
|
QJsonObject Jarmod::toJson()
|
|
|
|
{
|
|
|
|
QJsonObject out;
|
|
|
|
writeString(out, "name", name);
|
2015-06-01 01:15:28 +05:30
|
|
|
if(!originalName.isEmpty())
|
|
|
|
{
|
|
|
|
writeString(out, "originalName", originalName);
|
|
|
|
}
|
2014-05-11 16:07:21 +05:30
|
|
|
return out;
|
|
|
|
}
|