How to separate a string into several in java?

2

My problem is basically the following, I have a JSON code that takes the data from a URL, and returns it to me (Values are in Long)

528593
444218
5693595
2466912
2466435

However, it returns this to me in a single variable (in this case, "wtfbo"), and I need to split that into a string for each one to fit the interface I already have. In case, I'm currently using this code

  [...]
  Iterator<?> it = eat.iterator();
  while (it.hasNext()) {
      JSONObject dash = (JSONObject) it.next();
      Long wtfb10 = (Long) dash.get("teamId");

  if(wtfb10==100){
           Long wtfbo = (Long) dash.get("summonerId");
            String play = (String) dash.get("summonerName");
            String ko = wtfbo.toString();
            System.out.println(ko);
 }}
 [...]

Any ideas?

// EDIT: In short, "Long wtfbo" will return 5 different summonerId, but everything in it, I need it to return in 5 different strings, each having a summonerID.

    
asked by anonymous 05.03.2015 / 20:05

1 answer

2

I can not comment then ... rs. I do not quite understand if you just code the "summonerId" or the participant objects that contains this attribute.

To get an array of participant objects you could do something like the code below. Considering the json that is in the pastebin, to catch the participants:


JSONArray participantes = jsonData.getJSONArray("participants");
//manipula valores dos participantes
for (int i=0; i < participantes.length(); i++) {
    //participante no índice i
    JSONObject player = arrFilmes.getJSONObject(i);
    Long wtfbo = (Long) player.get("summonerId");
    ...
}
Then he would take the data from each participant and could structure it any way he wanted. Hope it helps in something and good luck.     
05.03.2015 / 20:50