mirror of
https://github.com/Serial-Studio/Serial-Studio.git
synced 2025-01-15 05:22:53 +08:00
Deal with \n and \r in JSON structure values
This commit is contained in:
parent
4a42742956
commit
a02129b811
@ -183,6 +183,13 @@ void Export::writeValues()
|
|||||||
auto datasetUnits = dataset.value("u").toVariant().toString();
|
auto datasetUnits = dataset.value("u").toVariant().toString();
|
||||||
auto datasetValue = dataset.value("v").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())
|
if (datasetTitle.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -101,6 +101,15 @@ bool Dataset::read(const QJsonObject &object)
|
|||||||
auto units = object.value("u").toVariant().toString();
|
auto units = object.value("u").toVariant().toString();
|
||||||
auto widget = object.value("w").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())
|
if (!value.isEmpty())
|
||||||
{
|
{
|
||||||
m_graph = graph;
|
m_graph = graph;
|
||||||
|
@ -93,6 +93,10 @@ bool Frame::read(const QJsonObject &object)
|
|||||||
auto title = object.value("t").toString();
|
auto title = object.value("t").toString();
|
||||||
auto groups = object.value("g").toArray();
|
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
|
// We need to have a project title and at least one group
|
||||||
if (!title.isEmpty() && !groups.isEmpty())
|
if (!title.isEmpty() && !groups.isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -100,6 +100,11 @@ bool Group::read(const QJsonObject &object)
|
|||||||
auto title = object.value("t").toVariant().toString();
|
auto title = object.value("t").toVariant().toString();
|
||||||
auto widget = object.value("w").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())
|
if (!title.isEmpty() && !array.isEmpty())
|
||||||
{
|
{
|
||||||
m_title = title;
|
m_title = title;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user