mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-10 23:46:00 -06:00
#3344 HoloLens export: Allow for more human-readable JSON text output
This commit is contained in:
parent
a40853dba5
commit
43ac06ca98
@ -60,10 +60,17 @@ void JsonReader::dumpToFile(std::vector<cvf::Vec3d>& points, QString filePath)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
QString Json::encode(const QMap<QString,QVariant> &map)
|
QString Json::encode(const QMap<QString,QVariant>& map, bool prettify)
|
||||||
{
|
{
|
||||||
QScriptEngine engine;
|
QScriptEngine engine;
|
||||||
engine.evaluate("function toString() { return JSON.stringify(this) }");
|
if (prettify)
|
||||||
|
{
|
||||||
|
engine.evaluate("function toString() { return JSON.stringify(this, null, ' ') }");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
engine.evaluate("function toString() { return JSON.stringify(this) }");
|
||||||
|
}
|
||||||
|
|
||||||
QScriptValue toString = engine.globalObject().property("toString");
|
QScriptValue toString = engine.globalObject().property("toString");
|
||||||
QScriptValue obj = encodeInner(map, &engine);
|
QScriptValue obj = encodeInner(map, &engine);
|
||||||
|
@ -53,7 +53,7 @@ class Json
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Json() {};
|
Json() {};
|
||||||
QString encode(const QMap<QString,QVariant> &map);
|
QString encode(const QMap<QString, QVariant>& map, bool prettify);
|
||||||
QMap<QString, QVariant> decode(const QString &jsonStr);
|
QMap<QString, QVariant> decode(const QString &jsonStr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user