ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: stoodin on June 01, 2014, 01:17:55 am
-
Hi,
I am sending the updateList from the grid getChanges to my Controller.
In Controller I am getting the JSONArray and when I iterate I am getting a "String" object that is essentially the JSONArray again.
What is the most efficient way to get the "updateList" to java Map or something I can extract key/value in my Controller.
Thanks a lot for your help.
Just additional info: I am not using ajax calls but rather pass the updateList as hidden variable from the jsp page to the controller.
I see in debugger that I am getting a JSONArray which has String array inside that is formatted as the JSONArray too but I am not able to cast it to JSONArray. The exception thrown saying it is a String type and the format is "[{"key":"Value"}]. I can certainly parse it as string but looking for more efficient way to do that.
Thanks a lot,
-
you could do it more conveniently by using a JSON library e.g., flexjson
import flexjson.JSONSerializer;
import flexjson.JSONDeserializer;
JSONDeserializer<List<T>> deserializer = new JSONDeserializer<List<T>>();
List<T> updateListArray = deserializer.deserialize( updateListString );
where T is row class/entity
Please let me know if you need any further assistance.
-
Thanks a lot Great Idea!
I made it work.
Thanks a lot. Your help is very valuable.
-
I'm glad you made it work.
Server side scripts for java ( spring framework ) have been added in the demos under java tab.
Particular code of relevance to your question (for anyone reading this post):
JSONDeserializer<List<T>> deserializer = new JSONDeserializer<List<T>>();
List<T> list = deserializer.use( "values", T.class ).deserialize(str);