i want convert javascript multidimensional array java object. have array stored in string. here example of array in string
string array = "[1,2,3,[3,2,4],['asdasda','test','tsdsdf'],3,2,['sddd']]";
and structure can in different example.
is there way convert array java object?
short answer: yes. ;-)
long answer: considering how similar java , javascript seem be, surprisingly hard.
first of all, input isn't in json format (for json, strings must use "
quotes), can't use 1 of many json parsing libraries gson or jackson.
so next option use javascript interpreter rhino, call evaluatestring() , examine result.
this gives javascript array instance feel odd use java perspective - remember, javascript arrays more hash maps plain java arrays plus javascript oddities.
if want value 5 such array, can use array.get(5, array);
last option write own parser.
Comments
Post a Comment