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:

  public static result redirectTest () {/ p> 

result result = redirect ("http: // ipaddress : 9000 / certify "); / *** Here I want to remove JSON string from result *** / return result; }

Application2:

  @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 ()); }    

Use JavaResultExtractor, example:

   

After having a byte array, you can remove the charset from the content-type header and create java.lang.String:

  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);   

Some of the above code was copied from

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -