Saturday 16 March 2019

JSONObject: Convert http header to json object


HTTP.toJSONObject method converts the http header to json object.

Example
JSONObject jsonObject = HTTP.toJSONObject("GET \"https://self-learning-java-tutorial.blogspot.com/2014/09/servlets.html\" HTTP/1.1");

App.java
package com.sample;

import org.json.HTTP;
import org.json.JSONObject;

public class App {

 public static void main(String args[]) {
  
  
  JSONObject jsonObject = HTTP.toJSONObject("GET \"https://self-learning-java-tutorial.blogspot.com/2014/09/servlets.html\" HTTP/1.1");
  
  System.out.println(jsonObject);


 }
}

Output
{"Request-URI":"https://self-learning-java-tutorial.blogspot.com/2014/09/servlets.html","Method":"GET","HTTP-Version":"HTTP/1.1"}



Previous                                                 Next                                                 Home

No comments:

Post a Comment