jsonRoutePoints.put(jsonPoint) 2010/1/7 Yury Luneff <bitter...@ya.ru>: > Hello! > > I have following code: > public String getRoutes() { > List<Route> routes = routeDAO.findAll(); > JSONArray jsonRoutes = new JSONArray(); > > for (Route route : routes) { > JSONArray jsonRoutePoints = new JSONArray(); > for (RoutePoint point : route.getPoints()) { > JSONObject jsonPoint = new JSONObject(); > jsonPoint.put("latitude", point.getLatitude()); > jsonPoint.put("longitude", point.getLongitude()); > jsonRoutePoints.put(jsonPoint.toString()); > } > jsonRoutes.put(jsonRoutePoints); > } > return jsonRoutes.toString(); > } > > Goal is to get a JSON object that is accesible like > "routes[0][0].latitude". But nested JSON objects are quoted by "\"" when > the > jsonRoutes.toString() is called. > > I receive an array of strings like > "{"longitude":38.94441,"latitude":47.203542}" > for each jsonPoint variable instead of > {"longitude":38.94441,"latitude":47.203542} > for each one. > > This happens because JSONObject's toString doesn't treat its > nested instances the way it probably should do. If jsonobject has > nested object the whole nested object should not be escaped. > > I guess the problem relies somewhere around > JSONObject.valueToString method. > > Or am I using JSONObject/JSONArray in a wrong way? > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >
-- Howard M. Lewis Ship Creator of Apache Tapestry The source for Tapestry training, mentoring and support. Contact me to learn how I can get you up and productive in Tapestry fast! (971) 678-5210 http://howardlewisship.com --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org