MCPcopy Create free account
hub / github.com/IBM/Project_CodeNet / JSON_escape

Function JSON_escape

tools/tokenizer/jstokenize.c:625–638  ·  view source on GitHub ↗

Escape token for output as JSON string.

Source from the content-addressed store, hash-verified

623
624// Escape token for output as JSON string.
625static void JSON_escape(FILE *out, const char *token)
626{
627 // To preserve, simply escape the escape and all ":
628 const char *p;
629 for (p = token; *p; p++) {
630 if (*p == '\n') {
631 fputs("\\n", out);
632 continue;
633 }
634 if (*p == '\\' || *p == '"')
635 fputc('\\', out);
636 fputc(*p, out);
637 }
638}
639
640// Escape token for output as XML text.
641static void XML_escape(FILE *out, const char *token)

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected