json - How to extract result content from play.mvc.Result object in play application? -
Actually, I'm redirecting to another play application with the application of a play, after all I responded as a result object I get the action in two applications below. I'm redirecting from apllication1 to application2. The app will return 2 JSON string, I need to remove.
Application1: result result = redirect ("http: // ipaddress : 9000 / certify "); / *** Here I want to remove JSON string from result *** / return result; } Application2: Use JavaResultExtractor, example: After having a byte array, you can remove the charset from the content-type header and create java.lang.String: Some of the above code was copied from
public static result redirectTest () {/ p>
@SecuredAction Public Static Results Index () {Map & lt; String, string & gt; Feedback = New Hashmap & lt; String, string & gt; (); Demo user user = (demoizer) CTX (). Args.get (SecureSocial.USER_KEY); (Basic Profile BasicProfile: User ID) {response.put ("name", basicProfile.firstName (). Get ()); Response.put ("emailId", basicProfile.email (). Get ()); Response.put ("providerId", basicProfile.providerId ()); Response.put ("avatarurl", Basic Profile. Avatar Yule (). Get ()); } The return is ok (new JSONObject (response) .toString ()); }
string header = JavaResultExtractor.getHeaders (results) .Get ("content type"); String charset = "UTF-8"; If (header! = Null and; header.contains ("; charset =") {charset = header.substring (header.indexOf ("charset =") + 10, header.length ()). Trim (); } String bodyStr = new string (body, charset); Jason Noded Bodyjason = Jason Pars (bodystrator);
Comments
Post a Comment