src/json.c

changeset 1582
32b82c424252
parent 1574
cfbf4a3a9c11
child 1583
97fc8c55aeea
equal deleted inserted replaced
1581:814049fb62ee 1582:32b82c424252
109 CxJsonTokenType ttype; 109 CxJsonTokenType ttype;
110 if (isstring) { 110 if (isstring) {
111 ttype = CX_JSON_TOKEN_STRING; 111 ttype = CX_JSON_TOKEN_STRING;
112 } else { 112 } else {
113 cxstring s = cx_strcast(str); 113 cxstring s = cx_strcast(str);
114 if (!cx_strcmp(s, CX_STR("true")) || !cx_strcmp(s, CX_STR("false")) 114 if (!cx_strcmp(s, "true") || !cx_strcmp(s, "false")
115 || !cx_strcmp(s, CX_STR("null"))) { 115 || !cx_strcmp(s, "null")) {
116 ttype = CX_JSON_TOKEN_LITERAL; 116 ttype = CX_JSON_TOKEN_LITERAL;
117 } else { 117 } else {
118 ttype = token_numbertype(str.ptr, str.length); 118 ttype = token_numbertype(str.ptr, str.length);
119 } 119 }
120 } 120 }
676 } 676 }
677 case CX_JSON_TOKEN_LITERAL: { 677 case CX_JSON_TOKEN_LITERAL: {
678 if ((vbuf = json_create_value(json, CX_JSON_LITERAL)) == NULL) { 678 if ((vbuf = json_create_value(json, CX_JSON_LITERAL)) == NULL) {
679 return_rec(CX_JSON_VALUE_ALLOC_FAILED); // LCOV_EXCL_LINE 679 return_rec(CX_JSON_VALUE_ALLOC_FAILED); // LCOV_EXCL_LINE
680 } 680 }
681 if (0 == cx_strcmp(cx_strcast(token.content), cx_str("true"))) { 681 if (0 == cx_strcmp(token.content, "true")) {
682 vbuf->literal = CX_JSON_TRUE; 682 vbuf->literal = CX_JSON_TRUE;
683 } else if (0 == cx_strcmp(cx_strcast(token.content), cx_str("false"))) { 683 } else if (0 == cx_strcmp(token.content, "false")) {
684 vbuf->literal = CX_JSON_FALSE; 684 vbuf->literal = CX_JSON_FALSE;
685 } else { 685 } else {
686 vbuf->literal = CX_JSON_NULL; 686 vbuf->literal = CX_JSON_NULL;
687 } 687 }
688 return_rec(CX_JSON_NO_ERROR); 688 return_rec(CX_JSON_NO_ERROR);

mercurial