Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | JSON CLI mode now accepts --indent|-I N to set JSON indention level (uses cson_output_opt::indentation semantics). Default for CLI mode is 1 (0 for HTTP mode). |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | json |
Files: | files | file ages | folders |
SHA1: |
30e4ebaa199af338c86f50421935f02e |
User & Date: | stephan 2011-09-28 21:36:15.726 |
Context
2011-09-28
| ||
22:04 | Added createIfNotExists bool option to /json/wiki/save. ... (check-in: 73e28dd7 user: stephan tags: json) | |
21:36 | JSON CLI mode now accepts --indent|-I N to set JSON indention level (uses cson_output_opt::indentation semantics). Default for CLI mode is 1 (0 for HTTP mode). ... (check-in: 30e4ebaa user: stephan tags: json) | |
12:09 | merged in trunk [3e141b792c]. ... (check-in: 033e2eb1 user: stephan tags: json) | |
Changes
Changes to ajax/index.html.
︙ | ︙ | |||
146 147 148 149 150 151 152 | TheApp.jqe.taRequest.val( val ); TheApp.jqe.taRequestOpt.val( opt ? WhAjaj.stringify(opt) : '' ); TheApp.startAjaxNotif(); }; opt.afterSend = function(req,opt) { TheApp.timer.end(); TheApp.endAjaxNotif(); | | | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | TheApp.jqe.taRequest.val( val ); TheApp.jqe.taRequestOpt.val( opt ? WhAjaj.stringify(opt) : '' ); TheApp.startAjaxNotif(); }; opt.afterSend = function(req,opt) { TheApp.timer.end(); TheApp.endAjaxNotif(); TheApp.jqe.timer.text( "(Round-trip time (incl. JS overhead): "+TheApp.timer.duration+'ms)' ); }; opt.onResponse = function(resp,req) { var val; try { val = WhAjaj.stringify(resp); } catch(e) { |
︙ | ︙ |
Changes to src/json.c.
︙ | ︙ | |||
389 390 391 392 393 394 395 396 397 398 | } rc = cson_object_get( g.json.post.o, zKey ); if(rc){ return rc; }else{ char const * cv = PD(zKey,NULL); if(!cv){ cv = getenv(zKey); } if(cv){/*transform it to JSON for later use.*/ | > > > > | > > > > > > > > > > > > | | > | 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | } rc = cson_object_get( g.json.post.o, zKey ); if(rc){ return rc; }else{ char const * cv = PD(zKey,NULL); if(!cv){ /* reminder to self: in CLI mode i'd like to try find_option(zKey,NULL,XYZ) here, but we don't have a sane default for the XYZ param here. */ cv = getenv(zKey); } if(cv){/*transform it to JSON for later use.*/ /* use sscanf() to figure out if it's an int, and transform it to JSON int if it is. */ int intVal = -1; char endOfIntCheck; int const scanRc = sscanf(cv,"%d%c",&intVal, &endOfIntCheck) /* The %c bit there is to make sure that we don't accept 123x as a number. sscanf() returns the number of tokens successfully parsed, so an RC of 1 will be correct for "123" but "123x" will have RC==2. */ ; if(1==scanRc){ json_setenv( zKey, cson_value_new_integer(intVal) ); }else{ rc = cson_value_new_string(cv,strlen(cv)); json_setenv( zKey, rc ); } return rc; } } return NULL; } /* |
︙ | ︙ | |||
932 933 934 935 936 937 938 | /* g.json.reqPayload.o may legally be NULL, which means only that g.json.reqPayload.v is-not-a Object. */; } {/* set up JSON output formatting options. */ unsigned char indent = g.isHTTP ? 0 : 1; | | > > > > | < | < < < | 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | /* g.json.reqPayload.o may legally be NULL, which means only that g.json.reqPayload.v is-not-a Object. */; } {/* set up JSON output formatting options. */ unsigned char indent = g.isHTTP ? 0 : 1; char const * indentStr = NULL; if( g.isHTTP ){ indent = (unsigned char)json_getenv_int("indent",(int)indent); }else{/*CLI mode*/ indentStr = find_option("indent","I",1); if(indentStr){ int const n = atoi(indentStr); indent = (n>0) ? (unsigned char)n : 0; } } g.json.outOpt.indentation = indent; g.json.outOpt.addNewline = g.isHTTP ? 0 : (g.json.jsonp ? 0 : 1); } |
︙ | ︙ | |||
1355 1356 1357 1358 1359 1360 1361 | cson_value_new_string(str,strlen(str)) ); } } db_finalize(&q); cson_object_set( obj, "permissionFlags", sub ); obj = cson_value_get_object(sub); | | | | | | | | | | | | | | | | | | | | | | | | | 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 | cson_value_new_string(str,strlen(str)) ); } } db_finalize(&q); cson_object_set( obj, "permissionFlags", sub ); obj = cson_value_get_object(sub); #define ADD(X,K) cson_object_set(obj, K, cson_value_new_bool(g.perm.X)) ADD(Setup,"setup"); ADD(Admin,"admin"); ADD(Delete,"delete"); ADD(Password,"password"); ADD(Query,"query"); /* don't think this one is actually used */ ADD(Write,"checkin"); ADD(Read,"checkout"); ADD(History,"history"); ADD(Clone,"clone"); ADD(RdWiki,"readWiki"); ADD(NewWiki,"createWiki"); ADD(ApndWiki,"appendWiki"); ADD(WrWiki,"editWiki"); ADD(RdTkt,"readTicket"); ADD(NewTkt,"createTicket"); ADD(ApndTkt,"appendTicket"); ADD(WrTkt,"editTicket"); ADD(Attach,"attachFile"); ADD(TktFmt,"createTicketReport"); ADD(RdAddr,"readPrivate"); ADD(Zip,"zip"); ADD(Private,"xferPrivate"); #undef ADD return payload; } /* ** Implementation of the /json/stat page/command. ** |
︙ | ︙ |