a4311d22ec503f936c0b624c13b1349c590a01ea angie Wed Apr 20 12:01:26 2016 -0700 Added an errCatch to cartJsonExecute so that instead of returning invalid JSON where there's an errAbort, we can close out the JSON-in-progress (if any) and add an error message to the JSON response -- then the user will at least see the error message instead of a parser error alert. This required extending jsonWrite's objStack so that in addition to tracking whether a comma is needed, it now tracks whether each stack item is an object or a list. Then, when necessary we can tell jsonWrite to pop up to a certain level (in this case, level 1 so we can include an error string in the response object) by closing out any lists or objects that are deeper than that level. The new flag also allows us to test for errors like ending a list when we need to end an object or vice versa. diff --git src/lib/jsonWrite.c src/lib/jsonWrite.c index ce342fc..5be896f 100644 --- src/lib/jsonWrite.c +++ src/lib/jsonWrite.c @@ -1,226 +1,248 @@ /* jsonWrite - Helper routines for writing out JSON. */ /* Copyright (C) 2014 The Regents of the University of California * See README in this or parent directory for licensing information. */ #include "common.h" #include "hash.h" #include "dystring.h" #include "sqlNum.h" #include "jsonParse.h" #include "jsonWrite.h" // Separator between elements; set this to "\n" to see elements on separate lines. // Newlines are fine in Javascript, e.g. in an embedded