MCPcopy Create free account
hub / github.com/Tencent/Hardcoder / cJSON_Minify

Function cJSON_Minify

libapp2sys/src/main/cpp/cjson/cJSON.c:2637–2705  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2635}
2636
2637CJSON_PUBLIC(void) cJSON_Minify(char *json)
2638{
2639 unsigned char *into = (unsigned char*)json;
2640
2641 if (json == NULL)
2642 {
2643 return;
2644 }
2645
2646 while (*json)
2647 {
2648 if (*json == ' ')
2649 {
2650 json++;
2651 }
2652 else if (*json == '\t')
2653 {
2654 /* Whitespace characters. */
2655 json++;
2656 }
2657 else if (*json == '\r')
2658 {
2659 json++;
2660 }
2661 else if (*json=='\n')
2662 {
2663 json++;
2664 }
2665 else if ((*json == '/') && (json[1] == '/'))
2666 {
2667 /* double-slash comments, to end of line. */
2668 while (*json && (*json != '\n'))
2669 {
2670 json++;
2671 }
2672 }
2673 else if ((*json == '/') && (json[1] == '*'))
2674 {
2675 /* multiline comments. */
2676 while (*json && !((*json == '*') && (json[1] == '/')))
2677 {
2678 json++;
2679 }
2680 json += 2;
2681 }
2682 else if (*json == '\"')
2683 {
2684 /* string literals, which are \" sensitive. */
2685 *into++ = (unsigned char)*json++;
2686 while (*json && (*json != '\"'))
2687 {
2688 if (*json == '\\')
2689 {
2690 *into++ = (unsigned char)*json++;
2691 }
2692 *into++ = (unsigned char)*json++;
2693 }
2694 *into++ = (unsigned char)*json++;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected