-2

I have created a Json string from my dynamic html table using the following link How to convert the following table to JSON with javascript?.

Now, how do I read this in java when my String looks like below:

{"myrows": [{
      "Event type":"Vitality Health Check",
      "Estimated number of insured employees":"100",
      "Estimated number of uninsured employees":"100",
      "Cost per Uninsured employee (incl VAT)":"10000",
      "Estimated total cost for uninsured employees (incl VAT)":"10000"
  }]
}

Thank you.

Arek
  • 3,106
  • 3
  • 23
  • 32

1 Answers1

0

I solved this issue by doing below.

JSONObject jsonObject = new JSONObject(INPUT_JSON_STRING);
    JSONArray array = new JSONArray(jsonObject.getString("myrows"));
    WellnessEventDetail wellnessEventDetail = null;
    for(int i=0; i<array.length(); i++){
        wellnessEventDetail = new WellnessEventDetail();
        JSONObject jsonObj  = array.getJSONObject(i);
        wellnessEventDetail.setEventType(jsonObj.getString("Event type"));
        .......
    }