Android Open Source - GenericServer J S O N Reply






From Project

Back to project page GenericServer.

License

The source code is released under:

GNU General Public License

If you think the Android project GenericServer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.davecoss.android.genericserver;
// w w w .j a v a 2  s.  com
import java.io.PrintWriter;
import java.util.HashMap;

import org.json.simple.JSONObject;


public class JSONReply extends HTTPReply {
  
  public JSONReply (String content) {
    super(content);
  }
  
  public String get_content_type() {
    return "Content-type: application/json";
  }
  
  @Override
  public void dump_head(PrintWriter output)
  {
    output.println(this.status);
    
    output.println(get_content_type());
    output.println("");
    output.flush();
  }
  

  @Override
  public void dump_body(PrintWriter output) {
    output.println(this.content);
    output.println("");
    output.flush();
  }
  
  @SuppressWarnings("unchecked")
  public static JSONReply fromHashmap(HashMap<String, String> content) {
    JSONObject json_content = new JSONObject(content);
    JSONObject json_data = new JSONObject();
    json_data.put("content", json_content);
    
    return new JSONReply(json_data.toString());
  }
}




Java Source Code List

com.davecoss.android.genericserver.BuildInfo.java
com.davecoss.android.genericserver.Console.java
com.davecoss.android.genericserver.EmptyRequest.java
com.davecoss.android.genericserver.FileError.java
com.davecoss.android.genericserver.FileReply.java
com.davecoss.android.genericserver.GenericServer.java
com.davecoss.android.genericserver.HTMLReply.java
com.davecoss.android.genericserver.HTTPError.java
com.davecoss.android.genericserver.HTTPReply.java
com.davecoss.android.genericserver.HTTPRequest.java
com.davecoss.android.genericserver.ImageReply.java
com.davecoss.android.genericserver.InvalidPostData.java
com.davecoss.android.genericserver.InvalidRequestData.java
com.davecoss.android.genericserver.JSONReply.java
com.davecoss.android.genericserver.Module.java
com.davecoss.android.genericserver.Plugin.java
com.davecoss.android.genericserver.SSLServer.java
com.davecoss.android.genericserver.ServerBundle.java
com.davecoss.android.genericserver.ServerHandler.java
com.davecoss.android.genericserver.Standalone.java
com.davecoss.android.genericserver.StreamReply.java
com.davecoss.android.genericserver.UserFile.java