Converting JavaScript Multi dimension Array into Java Array -
i using handsontable perform business operation while saving form retrieve data method
handsontable.getdata(); which returns (javascript array)
[[1,2,3],[4,5,6],[7,8,9]] but not able figure out way convert
list<list<integer>>
gson automatically. think done:
gson gson = new gson(); string json = "[[1,2,3],[4,5,6],[7,8,9]]"; java.lang.reflect.type.type listoflistsofintstype = new com.google.gson.reflect.typetoken.typetoken<list<list<integer>>>(){}.gettype(); list<list<integer>> list = gson.fromjson(json, listoflistsofintstype); you can skip typetoken business if define class member variable of type list<list<integer>> , pass class 2nd argument fromjson().
Comments
Post a Comment