File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
APIJSON-Java-Server/APIJSONLibrary/src/main/java/zuo/biao/apijson Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ public JSONRequest(String name, Object object) {
5454
5555 public static final String KEY_TAG = "tag" ;//只在最外层,最外层用JSONRequest
5656 public static final String KEY_VERSION = "version" ;//只在最外层,最外层用JSONRequest
57+ public static final String KEY_FORMAT = "format" ;//只在最外层,最外层用JSONRequest
5758
5859 /**set "tag":tag in outermost layer
5960 * for write operations
@@ -71,6 +72,14 @@ public JSONRequest setTag(String tag) {
7172 public JSONRequest setVersion (String version ) {
7273 return puts (KEY_VERSION , version );
7374 }
75+ /**set "format":format in outermost layer
76+ * for format APIJSON special keys to normal keys of response
77+ * @param version
78+ * @return
79+ */
80+ public JSONRequest setFormat (Boolean format ) {
81+ return puts (KEY_FORMAT , format );
82+ }
7483
7584
7685 //array object <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Original file line number Diff line number Diff line change @@ -136,6 +136,11 @@ public AbstractParser setGlobleDatabase(String globleDatabase) {
136136 this .globleDatabase = globleDatabase ;
137137 return this ;
138138 }
139+ protected boolean globleFormat ;
140+ public AbstractParser setGlobleFormat (Boolean globleFormat ) {
141+ this .globleFormat = globleFormat ;
142+ return this ;
143+ }
139144
140145 @ Override
141146 public boolean isNoVerify () {
@@ -265,7 +270,10 @@ public JSONObject parseResponse(JSONObject request) {
265270
266271 try {
267272 setGlobleDatabase (requestObject .getString (JSONRequest .KEY_DATABASE ));
273+ setGlobleFormat (requestObject .getBooleanValue (JSONRequest .KEY_FORMAT ));
274+
268275 requestObject .remove (JSONRequest .KEY_DATABASE );
276+ requestObject .remove (JSONRequest .KEY_FORMAT );
269277 } catch (Exception e ) {
270278 return extendErrorResult (requestObject , e );
271279 }
@@ -306,7 +314,7 @@ public JSONObject parseResponse(JSONObject request) {
306314 Log .d (TAG , "parseResponse endTime = " + endTime + "; duration = " + (endTime - startTime )
307315 + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n \n \n " );
308316
309- return requestObject ;
317+ return globleFormat ? new JSONResponse ( requestObject ) : requestObject ;
310318 }
311319
312320
You can’t perform that action at this time.
0 commit comments