23 #define JSON_BEGIN() int __i = STRING_ITERATOR_SAVE(_json) 24 #define JSON_FAIL(reason) goto fail 28 STRING_ITERATOR_LOAD(_json, __i); \ 78 bool required =
false;
79 for (
int n = 0; ; n++) {
86 if (required)
JSON_FAIL(
"expected value");
else break;
159 }
else if (c ==
'\\') {
163 JSON_FAIL(
"expected ( '\"' | '\\' | 'n' | 't' )");
164 case '"': esc =
"\"";
break;
165 case '\\': esc =
"\\";
break;
166 case 'n': esc =
"\n";
break;
167 case 't': esc =
"\t";
break;
168 case 'u': esc =
"\\u";
break;
169 case '/': esc =
"/";
break;
195 if (!(c >=
'0' && c <=
'9')) {
196 if (c ==
'.' && needdot) {
206 if (s ==
"")
JSON_FAIL(
"expected float");
216 if (!(c >=
'0' && c <=
'9')) {
220 if (s ==
"" && c ==
'0')
JSON_FAIL(
"expected [1-9]");
236 part = strreplace(
" ",
"", part);
237 part = strreplace(
"\n",
"", part);
238 trimmed =
strcat(trimmed, part);
242 part = strreplace(
" ",
"", part);
243 part = strreplace(
"\n",
"", part);
244 trimmed =
strcat(trimmed, part);
251 if (o < esc || esc < 0) {
254 trimmed =
strcat(trimmed, part);
259 trimmed =
strcat(trimmed, part);
278 for (
int i = 1, n = buf_getsize(buf); i < n; i += 2) {
279 if (bufstr_get(buf, i) == key)
return bufstr_get(buf, i + 1);
293 for (
int i = 0, n = buf_getsize(buf); i < n; ++i) {
294 print(bufstr_get(buf, i),
"\n");
305 \"m_string\": \"\\\"string\\\"\",\n\
ERASEABLE int json_parse(string in, bool() func)
bool _json_parse_number()
bool _json_parse_members()
#define EXPECT_NE(val1, val2)
#define SUCCEED()
Must be present at the end of a test.
ERASEABLE string json_get(int buf, string key)
#define STRING_ITERATOR_UNGET(this)
#define STRING_ITERATOR_NEXT(this)
STRING_ITERATOR(_json, string_null, 0)
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
ERASEABLE void json_dump(int buf)
bool _json_parse_string(bool add)
#define STRING_ITERATOR_GET(this)
bool _json_parse_object()
parse a json object
#define JSON_FAIL(reason)
#define WITH(type, name, value, block)
#define STRING_ITERATOR_SET(this, s, i)
ERASEABLE string cons(string a, string b)
#define STRING_ITERATOR_PEEK(this)
ERASEABLE void json_del(int buf)