Deal with \n and \r in JSON structure values

This commit is contained in:
Alex Spataru 2021-02-18 00:59:59 -05:00
parent 4a42742956
commit a02129b811
4 changed files with 25 additions and 0 deletions

View File

@ -183,6 +183,13 @@ void Export::writeValues()
auto datasetUnits = dataset.value("u").toVariant().toString();
auto datasetValue = dataset.value("v").toVariant().toString();
datasetTitle = datasetTitle.replace("\n", "");
datasetUnits = datasetUnits.replace("\n", "");
datasetValue = datasetValue.replace("\n", "");
datasetTitle = datasetTitle.replace("\r", "");
datasetUnits = datasetUnits.replace("\r", "");
datasetValue = datasetValue.replace("\r", "");
if (datasetTitle.isEmpty())
continue;

View File

@ -101,6 +101,15 @@ bool Dataset::read(const QJsonObject &object)
auto units = object.value("u").toVariant().toString();
auto widget = object.value("w").toVariant().toString();
title = title.replace("\n", "");
title = title.replace("\r", "");
value = value.replace("\n", "");
value = value.replace("\r", "");
units = units.replace("\n", "");
units = units.replace("\r", "");
widget = widget.replace("\n", "");
widget = widget.replace("\r", "");
if (!value.isEmpty())
{
m_graph = graph;

View File

@ -93,6 +93,10 @@ bool Frame::read(const QJsonObject &object)
auto title = object.value("t").toString();
auto groups = object.value("g").toArray();
// Remove line breaks from title
title = title.replace("\n", "");
title = title.replace("\r", "");
// We need to have a project title and at least one group
if (!title.isEmpty() && !groups.isEmpty())
{

View File

@ -100,6 +100,11 @@ bool Group::read(const QJsonObject &object)
auto title = object.value("t").toVariant().toString();
auto widget = object.value("w").toVariant().toString();
title = title.replace("\n", "");
title = title.replace("\r", "");
widget = widget.replace("\n", "");
widget = widget.replace("\r", "");
if (!title.isEmpty() && !array.isEmpty())
{
m_title = title;