EWA DEMO emp-script emp-script-utils emp-script-static ffmpeg-utils weixin

[更新] com.gdxsoft.easyweb.data.DTRow 创建json字段大小写

2016-05-23

包:com.gdxsoft.easyweb.data

类:DTRow

方法:toJson

处理toJson的添加upperOrLower的参数,UPPER表示大写,LOWER表示小写,参数大小写无关。其它则无变化。

/**
 * 返回json对象
 * 
 * @param upperOrLower
 *            UPPER or LOWER 指定字段大写或小写
 * @return
 * @throws JSONException
 */
public JSONObject toJson(String upperOrLower) throws JSONException {
    JSONObject rowJson = new JSONObject();
    for (int i = 0; i < this._Table.getColumns().getCount(); i++) {

        Object val = this.getCell(i).getValue();

        String name = this._Table.getColumns().getColumn(i).getName();
        if (upperOrLower != null) {
            if (upperOrLower.toUpperCase().equals("UPPER")) {
                name = name.toUpperCase();
            } else if (upperOrLower.toUpperCase().equals("LOWER")) {
                name = name.toLowerCase();
            }
        }
        rowJson.put(name, val );
    }
    return rowJson;
}