Posted 07 July 2015 - 10:54 PM
VERSION
CC 1.7.3 (as part of DW20 1.5.0) on MC 1.7.10 (forge 1448)
For the peanuts that it matters, fastcraft is enabled, but this is not a rendering issue.
EXPECTED RESULT
Newlines processed by seralizeJSON to be replaced by \n
ACTUAL RESULT
Newlines excaped by backslashes instead of being replaced
WORKAROUND
Simply use string.gsub to replace '\n' with 'n' after serializeJSON has run.
OTHER THOUGHTS
Textutils seems to just use the string formatter's %q, which just quotes the string, and does not nessacaraly deal with excaping correctly.
Test
Screenshot
CC 1.7.3 (as part of DW20 1.5.0) on MC 1.7.10 (forge 1448)
For the peanuts that it matters, fastcraft is enabled, but this is not a rendering issue.
EXPECTED RESULT
Newlines processed by seralizeJSON to be replaced by \n
ACTUAL RESULT
Newlines excaped by backslashes instead of being replaced
WORKAROUND
Simply use string.gsub to replace '\n' with 'n' after serializeJSON has run.
OTHER THOUGHTS
Textutils seems to just use the string formatter's %q, which just quotes the string, and does not nessacaraly deal with excaping correctly.
Test
function newlineJSONTest()
local inString ="Hello\
World";
local expectedString = "\"Hello\\nWorld\"";
local outStr = textutils.serializeJSON(inString);
if outStr ~= expectedString then
print("Expected: "..expectedString);
print("Recieved: "..outStr)
return false
else
return true;
end
end
if newlineJSONTest() then
print("Newlines in JSON: PASS");
else
print("Newlines in JSON: FAIL");
end
Screenshot
Edited on 10 July 2015 - 09:55 PM