Created
April 14, 2015 21:00
-
-
Save cazala/72a4988b41883c0a77b7 to your computer and use it in GitHub Desktop.
API Template: JSON Wrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // replace {{projectPkg}} | |
| package org.mule.{{projectPkg}}.utils; | |
| import org.json.JSONObject; | |
| public class JsonWrapper { | |
| public static JSONObject wrapMessage(String data, boolean isSuccessful, String errorMsg) { | |
| StringBuilder jsonString = new StringBuilder("{"); | |
| jsonString.append("\"data\":" + data + ","); | |
| jsonString.append("\"isSuccessful\":\"" + isSuccessful + "\","); | |
| jsonString.append("\"message\":\"" + errorMsg + "\""); | |
| jsonString.append("}"); | |
| JSONObject json = new JSONObject(jsonString.toString()); | |
| return json; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment