I am developing an application in which I am using GET REST call to get some specific nodes which return’s me the nodes in the below json format:
[
{
"nodeId": "30",
"datasetId": "2",
"localId": "30",
"datasetName": "Optimal Travel Route",
"nodeName": "Location30",
"nodeDesc": "Find the optimal travel route using travelling salesman problem ",
"nodeStatus": "Private",
"gpsLat": "8.233240",
"gpsLong": "15.029300",
"addedBy": "internIITD",
"addedOn": "2012-06-29 11:08:28",
"updatedOn": "2012-06-29 11:08:28"
}
]
they are no newlines .I have added here to make it readable. I am doing this to convert it to string.:
BufferedReader in = new BufferedReader(new InputStreamReader(
httpCon.getInputStream()));
String inputLine;
StringBuilder sb = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
sb.append(inputLine);
System.out.println(inputLine);
}
String Result;
Result=sb.toString();
System.out.println("result:"+Result);
I want to extract the longitude and latitude of the nodes that will be given meeting specific requirements. I am working in NetBeans 7.1.2 . I am new to JAVA.
So , can anyone tell is there any way to extract this latitude and longitde information and store it in integer varibles.
I used to declare JSONObject but it is not working here .I don’t know why?I am not able to use JSONArray or JSONObect in my code. It is showing me an error.In the class in which I am doing this does not have a mail function. this class i.e. file has been called by some other .java file . I have multiple windows in my application.
Please help.
This would be a solution:
This would print: