java - decode and encode a json encoded array of coordinates using jackson -


i've built server in java accepts json encoded array of coordinates respresented array containg latitude , longitude.

so looks this

[["48.72028","21.25768"],["48.71669000000001","21.253410000000002"]] 

now need decode array of coordinate. coordinate com.vividsolutions.jts.geom.coordinate.

this array represents polyline transformed polygon. polyline hundreds of points long. need send polygon encoded in json client

until have used google gson, slow. json decoding , encoding takes more time polygon transformation.

after little googling got impression jackson should fastest.

but i'm php developer json decode , encode 1 line , first time writing java, have no idea how use it.

how decode json in coordinate[] array, , encode similar array json again?

thanks

if understood question, it's array of arrays. not sure approach here work (sorry don't have test environment here). however, works fine, array of objects:

objectmapper mapper = new objectmapper();     javatype type = mapper.gettypefactory().constructcollectiontype(arraylist.class, arraylist.class) ;     list<list> results;    try {         results = (list<list>)mapper.readvalue(jsondata, type);          coordinate[] coordinates = new coordinate[results.size()];      (int = 0; < list.size(); i++) {        coordinates[i] = new coordinate(double.parsedouble((string)results.get(i).get(0)),double.parsedouble((string)results.get(i).get(1)));      }   } catch (jsonparseexception e) {   } catch (jsonmappingexception e) {   } catch (ioexception e) {   } 

i hope helps


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -