@@ -155,7 +155,7 @@ public ObjectParser parse() throws Exception {
155155 key = entry .getKey ();
156156
157157 if (value instanceof JSONObject ) {//JSONObject,往下一级提取
158- putChild (key , onChildParse ( key , ( JSON ) value ) );
158+ putChild (key , ( JSON ) value );
159159 } else if (method == PUT && value instanceof JSONArray ) {//PUT JSONArray
160160 onPUTArrayParse (key , (JSONArray ) value );
161161 } else {//JSONArray或其它Object,直接填充
@@ -186,10 +186,10 @@ public ObjectParser parse() throws Exception {
186186 */
187187 protected void putChild (String key , JSON child ) throws Exception {
188188 if (child != null ) {
189- if (childMap != null ) {
189+ if (childMap != null ) {//添加到childMap,最后再解析
190190 childMap .put (key , child );
191- } else {
192- response .put (key , child );
191+ } else {//直接解析并替换原来的
192+ response .put (key , onChildParse ( key , child ) );
193193 }
194194 }
195195 }
@@ -408,14 +408,21 @@ public ObjectParser executeSQL(int count, int page, int position) throws Excepti
408408 * @throws Exception
409409 */
410410 public JSONObject response () throws Exception {
411- if (sqlReponse != null ) {
411+ if (sqlReponse == null || sqlReponse .isEmpty ()) {
412+ if (isTableKey ) {//Table自身都获取不到值,则里面的Child都无意义,不需要再解析
413+ return response ;
414+ }
415+ } else {
412416 response .putAll (sqlReponse );
413417 }
414418
415- if (customMap != null ) {//把isTableKey时取出去的custom重新添加回来
419+ //把isTableKey时取出去的custom重新添加回来
420+ if (customMap != null ) {
416421 response .putAll (customMap );
417422 }
418- if (functionMap != null ) {//解析函数function
423+
424+ //解析函数function
425+ if (functionMap != null ) {
419426 Set <Entry <String , String >> functionSet = functionMap == null ? null : functionMap .entrySet ();
420427 if (functionSet != null && functionSet .isEmpty () == false ) {
421428 for (Entry <String , String > entry : functionSet ) {
@@ -425,10 +432,16 @@ public JSONObject response() throws Exception {
425432 }
426433 }
427434
428- if (childMap != null ) {//把isTableKey时取出去的child重新添加回来
429- response .putAll (childMap );
435+ //把isTableKey时取出去child解析后重新添加回来
436+ Set <Entry <String , JSON >> set = childMap == null ? null : childMap .entrySet ();
437+ if (set != null ) {
438+ for (Entry <String , JSON > entry : set ) {
439+ if (entry != null ) {
440+ response .put (entry .getKey (), onChildParse (entry .getKey (), entry .getValue ()));
441+ }
442+ }
430443 }
431-
444+
432445 onComplete ();
433446
434447 return response ;
0 commit comments