do not quote nor escape integers and booleans,
escape line ends,
escape backslash
--- a/src/YAMLHandler.h Wed Dec 23 18:22:55 2020 +0100
+++ b/src/YAMLHandler.h Wed Dec 23 18:29:36 2020 +0100
@@ -47,7 +47,10 @@
std::stringstream result;
result.put(Q);
for (char ch : convertor.to_bytes(value)) {
- if (ch == Q) result.put(ESC).put(ch);
+ if (ch == ESC) result.put(ESC).put(ch);
+ else if (ch == Q) result.put(ESC).put(ch);
+ else if (ch == '\n') result.put(ESC).put('n');
+ else if (ch == '\r') result.put(ESC).put('r');
else result.put(ch);
}
result.put(Q);
@@ -89,7 +92,10 @@
}
output << escape(currentAttributes[currentAttributeIndex].getAttributeName()) << ": ";
- output << escape(value) << std::endl;
+
+ if (currentAttributes[currentAttributeIndex].getTypeId() == relpipe::reader::TypeId::INTEGER) output << convertor.to_bytes(value) << std::endl;
+ else if (currentAttributes[currentAttributeIndex].getTypeId() == relpipe::reader::TypeId::BOOLEAN) output << convertor.to_bytes(value) << std::endl;
+ else output << escape(value) << std::endl;
currentAttributeIndex++;
}