Package org.zkoss.json.parser

Examples of org.zkoss.json.parser.JSONParser


   * If in is null, null is returned.
   *
   */
  public static Object parse(Reader in) throws java.io.IOException {
    if (in == null) return null;
    JSONParser parser=new JSONParser();
    return parser.parse(in);
  }
View Full Code Here


  public static double[] getLatlngByAddress (String address, boolean sensor, String language)
    throws ParseException, UnsupportedEncodingException, MalformedURLException, IOException {
    StringBuilder sb = getGeocodeJsonResult(address, sensor, language);
    double[] latlng = new double[2];

    JSONArray results = (JSONArray)((JSONObject)new JSONParser().parse(sb.toString())).get("results");
    JSONObject location = (JSONObject)((JSONObject)((JSONObject)results.get(0)).get("geometry")).get("location");
    latlng[0] = ((Double)location.get("lat")).doubleValue();
    latlng[1] = ((Double)location.get("lng")).doubleValue();
    return latlng;
  }
View Full Code Here

  public static double[] getBoundsByAddress (String address, boolean sensor, String language)
    throws ParseException, UnsupportedEncodingException, MalformedURLException, IOException {
    StringBuilder sb = getGeocodeJsonResult(address, sensor, language);
    double[] bounds = new double[4];
 
    JSONArray results = (JSONArray)((JSONObject)new JSONParser().parse(sb.toString())).get("results");
    JSONObject boundsInfo = (JSONObject)((JSONObject)((JSONObject)results.get(0)).get("geometry")).get("bounds");
    bounds[0] = ((Double)((JSONObject)boundsInfo.get("southwest")).get("lat")).doubleValue();
    bounds[1] = ((Double)((JSONObject)boundsInfo.get("southwest")).get("lng")).doubleValue();
    bounds[2] = ((Double)((JSONObject)boundsInfo.get("northeast")).get("lat")).doubleValue();
    bounds[3] = ((Double)((JSONObject)boundsInfo.get("northeast")).get("lng")).doubleValue();
View Full Code Here

  public static String getAddressByLatlng (double lat, double lng, boolean sensor, String language)
    throws ParseException, UnsupportedEncodingException, MalformedURLException, IOException {
    StringBuilder sb = getGeocodeJsonResult(lat, lng, sensor, language);
    String address = null;
   
    JSONArray results = (JSONArray)((JSONObject)new JSONParser().parse(sb.toString())).get("results");
    address = (String)((JSONObject)results.get(1)).get("formatted_address");
    return address;
  }
View Full Code Here

TOP

Related Classes of org.zkoss.json.parser.JSONParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.