I have to parse the following data
{"ResultSet":{"Query":"microsec fin","Result":
[{"symbol":"MICROSE_a.NS","name": "MICROSEC FIN SERV LTD ","exch": "NSI","type": "S","exchDisp":"NSE","typeDisp":"Equity"},
{"symbol":"MICROSEC.NS","name": "Microsec Fin Serv Ltd","exch": "NSI","type": "S","exchDisp":"NSE","typeDisp":"Equity"}]}}
The code i am using is
JSONObject json = (JSONObject) JSONSerializer.toJSON(inputLine);
symbol=json.getJSONObject("ResultSet").getJSONArray("Result").getJSONObject(0).getString("symbol");
which returns MICROSE_a.NS. What i want to do is if there is an undersore in symbol then i want the next symbol to be taken. That is now i want symbol to actually hold MICROSEC.NS. How do i do this.
Or which is much simpler with your library:
JSONArray Result= json.getJSONObject("ResultSet").getJSONArray("Result");
for(int i = 0; i<Result.length(); i++){
String symbol = Result.getJSONObject(i).getString("Symbol");
if(!symbol.contains("_"))
return symbol;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.