I am working on jquery datatable
plugin with wiki rest service
. I am stuck at, to convert string like structure as follows
[{"name":"sEcho","value":1},{"name":"iColumns","value":5}]
into map of objects. like ::
{"sEcho"=1, "iColumns"=5, "bSearchable_4"=true, "sSearch_3"="", "bRegex_3"=false, "mDataProp_3"=3, "sSearch_1"="", "bSortable_0"=true, "bRegex_1"=false}
Question is, Is there any generic way or library to do?
I am tried the fallowing -
queryJson = queryJson.replace("[", "");
queryJson = queryJson.replace("]", "");
String[] params = queryJson.split("},");
Map<String, Object> paramMap = new HashMap<String, Object>();
for(int i=0;i<params.length-1;i++){
String[] curObj = params[i].split(":");
String[] keyObj = curObj[1].split(",");
paramMap.put(keyObj[0], curObj[2]);
}
Getting output. But i think there might be better way to do. Please suggest me any library or generic way to do this. Thanks