java中获取到附件存储的json后要从中获取docID、fileID等信息,需要对json传进行解析
参考如下:
final String DATA_MODEL = "/demo/misc/data"; String ksql = "Select sendDoc.* from DEMO_SendDoc sendDoc"; Table table = KSQL.select(ksql, null, DATA_MODEL, null); Row row = table.getRow("sendDoc", "CB2ED0E4FBBF421583CE48D7B6E74A4A"); String attachmentInfo = row.getString("fAttachment");//获取到存储附件信息的字段值 JSONArray ja = JSONArray.parseArray(attachmentInfo);//把json传转换为JSONArray对象 for (int i = 0; i < ja.size(); i++) {//解析JSONArray获取具体的附件信息 JSONObject jsonObject = ja.getJSONObject(i); String docID = jsonObject.getString("docID"); String fileID = jsonObject.getString("fileID"); }
需要注意的是java中需要导入json相关的列
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONException;
评一波