【问题标题】:Unpacking json string in Java which is created of dynamic html table在Java中解包由动态html表创建的json字符串
【发布时间】:2017-07-17 11:16:36
【问题描述】:

我使用以下链接从我的动态 html 表中创建了一个 Json 字符串 How to convert the following table to JSON with javascript?.

现在,当我的字符串如下所示时,如何在 java 中读取此内容:

{"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"
  }]
}

谢谢。

【问题讨论】:

  • 感谢您编辑 Arek。下次记得。

标签: java json


【解决方案1】:

我通过以下操作解决了这个问题。

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"));
        .......
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-05
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    相关资源
    最近更新 更多