| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 93d4ab1 commit e482237
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -54,6 +54,7 @@ public JSONRequest(String name, Object object) { | |||
| 54 | 54 | ||
| 55 | 55 | public static final String KEY_TAG = "tag";//只在最外层,最外层用JSONRequest | |
| 56 | 56 | public static final String KEY_VERSION = "version";//只在最外层,最外层用JSONRequest | |
| 57 | + public static final String KEY_FORMAT = "format";//只在最外层,最外层用JSONRequest | ||
| 57 | 58 | ||
| 58 | 59 | /**set "tag":tag in outermost layer | |
| 59 | 60 | * for write operations | |
@@ -71,6 +72,14 @@ public JSONRequest setTag(String tag) { | |||
| 71 | 72 | public JSONRequest setVersion(String version) { | |
| 72 | 73 | return puts(KEY_VERSION, version); | |
| 73 | 74 | } | |
| 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 | + } | ||
| 74 | 83 | ||
| 75 | 84 | ||
| 76 | 85 | //array object <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -136,6 +136,11 @@ public AbstractParser setGlobleDatabase(String globleDatabase) { | |||
| 136 | 136 | this.globleDatabase = globleDatabase; | |
| 137 | 137 | return this; | |
| 138 | 138 | } | |
| 139 | + protected boolean globleFormat; | ||
| 140 | + public AbstractParser setGlobleFormat(Boolean globleFormat) { | ||
| 141 | + this.globleFormat = globleFormat; | ||
| 142 | + return this; | ||
| 143 | + } | ||
| 139 | 144 | ||
| 140 | 145 | @Override | |
| 141 | 146 | public boolean isNoVerify() { | |
@@ -265,7 +270,10 @@ public JSONObject parseResponse(JSONObject request) { | |||
| 265 | 270 | ||
| 266 | 271 | try { | |
| 267 | 272 | setGlobleDatabase(requestObject.getString(JSONRequest.KEY_DATABASE)); | |
| 273 | + setGlobleFormat(requestObject.getBooleanValue(JSONRequest.KEY_FORMAT)); | ||
| 274 | + | ||
| 268 | 275 | requestObject.remove(JSONRequest.KEY_DATABASE); | |
| 276 | + requestObject.remove(JSONRequest.KEY_FORMAT); | ||
| 269 | 277 | } catch (Exception e) { | |
| 270 | 278 | return extendErrorResult(requestObject, e); | |
| 271 | 279 | } | |
@@ -306,7 +314,7 @@ public JSONObject parseResponse(JSONObject request) { | |||
| 306 | 314 | Log.d(TAG, "parseResponse endTime = " + endTime + "; duration = " + (endTime - startTime) | |
| 307 | 315 | + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n\n"); | |
| 308 | 316 | ||
| 309 | - return requestObject; | ||
| 317 | + return globleFormat ? new JSONResponse(requestObject) : requestObject; | ||
| 310 | 318 | } | |
| 311 | 319 | ||
| 312 | 320 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments