Changeset 321 for tools

Show
Ignore:
Timestamp:
05/07/09 14:02:35 (16 months ago)
Author:
anton
Message:

Input JSON object now contains an array of point instead of comma separated list.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • tools/routingservice/branches/wrs-2.0/src/util/format/JSONParser.java

    r314 r321  
    2424import java.util.Vector; 
    2525 
     26import org.json.JSONArray; 
    2627import org.json.JSONException; 
    2728import org.json.JSONObject; 
     
    4950                                { 
    5051                                case POINTS: 
    51                                         String data = json.getString(key); 
    52                                         StringTokenizer st = new StringTokenizer(data, ","); 
    53                                         int i = 1; 
    54                                         while (st.hasMoreTokens()) 
     52                                        JSONArray data = json.getJSONArray(key); 
     53                                        for(int i = 0; i < data.length(); ++i) 
    5554                                        { 
    56                                                 String token = st.nextToken(); 
    57                                                 StringTokenizer sst = new StringTokenizer(token, " "); 
     55                                                String point = data.getString(i); 
     56                                                StringTokenizer sst = new StringTokenizer(point, " "); 
    5857                                                Parameter x = new Parameter(); 
    59                                                 x.setName("x" + i); 
     58                                                x.setName("x" + (i+1)); 
    6059                                                x.setSource("url"); 
    6160                                                x.setValue(sst.nextToken().trim()); 
     
    6564 
    6665                                                Parameter y = new Parameter(); 
    67                                                 y.setName("y" + i); 
     66                                                y.setName("y" + (i+1)); 
    6867                                                y.setSource("url"); 
    6968                                                y.setValue(sst.nextToken().trim());