summaryrefslogtreecommitdiff
path: root/src/support/json.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-02-20 13:23:10 -0800
committerGitHub <noreply@github.com>2024-02-20 13:23:10 -0800
commit07b91a81c169091b2464e6d587666ad3f0124a1e (patch)
treecc0df6add42ef4d9f30ea7db6a4171ca8461d18d /src/support/json.cpp
parentd0fa7102b5be83be6d0670a5662013bf5f8d1b64 (diff)
downloadbinaryen-07b91a81c169091b2464e6d587666ad3f0124a1e.tar.gz
binaryen-07b91a81c169091b2464e6d587666ad3f0124a1e.tar.bz2
binaryen-07b91a81c169091b2464e6d587666ad3f0124a1e.zip
StringLowering: Escape the JSON in the custom section (#6316)
Also add an end-to-end test using node to verify we can parse the escaped content properly using TextDecoder+JSON.parse.
Diffstat (limited to 'src/support/json.cpp')
-rw-r--r--src/support/json.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/support/json.cpp b/src/support/json.cpp
index d43ac0323..ab55cc75f 100644
--- a/src/support/json.cpp
+++ b/src/support/json.cpp
@@ -15,13 +15,13 @@
*/
#include "support/json.h"
+#include "support/string.h"
namespace json {
void Value::stringify(std::ostream& os, bool pretty) {
if (isString()) {
- // TODO: escaping
- os << '"' << getCString() << '"';
+ wasm::String::printEscapedJSON(os, getCString());
} else if (isArray()) {
os << '[';
auto first = true;