Code example for Gson

Methods: toJson

0
	public void updateTask(RemoteTask remoteTask) throws Exception {
 
		List<BasicNameValuePair> nvps = new ArrayList<BasicNameValuePair>();
		nvps.add(new BasicNameValuePair("action", "update"));
		nvps.add(new BasicNameValuePair("id", remoteTask.getId()));
		nvps.add(new BasicNameValuePair("summary", gson.toJson(remoteTask.getSummary())));
		nvps.add(new BasicNameValuePair("description", remoteTask.getDescription()));
		nvps.add(new BasicNameValuePair("content", gson.toJson(remoteTask
				.getContent()))); 
 
		httpPost.setEntity(new UrlEncodedFormEntity(nvps));
		HttpResponse response = httpclient.execute(httpPost);
 
		String status = response.getStatusLine().toString();
		System.out.println(status);
 
	} 
 
	/** 
	 * Delete an entry in the remote database 
Experience pair programming with AI  Get Codota for Java