I have written a Java program (using main method only) for sending HTML content using JSON. i have some data in my object in separate program which i want to import programmatically in my page of Atlassian Confluence. Still i am able to insert only static html content and data inside body of my page. i never worked before with json. how to insert data in row of table.
public class Example {
 private static final String BASE_URL = "www.example.com";
 private static final String USERNAME = "xxxxx";
 private static final String PASSWORD = "xxxxx";
 private static final String ENCODING = "utf-8";
 
 static HttpResponse putPageResponse;
 static HttpEntity putPageEntity = null;
 private static String getContentRestUrl(final Long contentId,
   final String[] expansions) throws UnsupportedEncodingException {
   final String expand = URLEncoder.encode(StringUtils.join(expansions, ","), ENCODING);
  return String
    .format("%s/rest/api/content/%s?expand=%s&os_authType=basic&os_username=%s&os_password=%s",
      BASE_URL, contentId, expand,
      URLEncoder.encode(USERNAME, ENCODING),
      URLEncoder.encode(PASSWORD, ENCODING));
 }
 public static void main(final String[] args) throws Exception {
  final long pageId = 00000000;
  HttpClient client = new DefaultHttpClient();
  // Get current page version
  String pageObj = null;
  HttpEntity pageEntity = null;
  try {
   HttpGet getPageRequest = new HttpGet(getContentRestUrl(pageId,
     new String[] { "body.storage", "version", "ancestors" }));
   
   HttpResponse getPageResponse = client.execute(getPageRequest);
   
   pageEntity = getPageResponse.getEntity();
   pageObj = IOUtils.toString(pageEntity.getContent());
  
  } finally {
   if (pageEntity != null) {
    EntityUtils.consume(pageEntity);
   }
  }
  // Parse response into JSON
  JSONObject page = new JSONObject(pageObj);
  try {
 
  **page.getJSONObject("body").getJSONObject("storage")
  .put("value","<b>html content here<b>");**
  <!--if i try to write any thing in second param of put() than it replace the all content of body with that.-->
  
  int currentVersion = page.getJSONObject("version").getInt("number");
  page.getJSONObject("version").put("number", currentVersion + 1);
  // Send update request
  
   HttpPut putPageRequest = new HttpPut(getContentRestUrl(pageId,
     new String[] {}));
   StringEntity entity = new StringEntity(page.toString(),
     ContentType.APPLICATION_JSON);
   putPageRequest.setEntity(entity);
   putPageResponse = client.execute(putPageRequest);
   System.out.println("");
   EntityUtils.consume(putPageEntity);
  
   
  } catch(Exception e) {
   System.out.println("exception is: "+e);
  }
 }
}
** if any one share any sample code for that that will very helpfull for me. i have following table in my page.
__________________________________________|
| S.no     | book title    |  book author    | publish date    |  price
|_____|________|___________|__________|______|