Example usage for org.json.simple JSONObject get

List of usage examples for org.json.simple JSONObject get

Introduction

In this page you can find the example usage for org.json.simple JSONObject get.

Prototype

V get(Object key);

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:gov.nasa.jpl.xdata.nba.impoexpo.parse.ParseUtil.java

public static List<Officials> parseOfficials(JSONObject jsonObject) {
    JSONArray resultSets = (JSONArray) jsonObject.get("resultSets");
    JSONObject infoObject = (JSONObject) resultSets.get(7);
    JSONArray rowSet = (JSONArray) infoObject.get("rowSet");
    List<Officials> result = new ArrayList<Officials>();
    for (Object rowObject : rowSet) {
        JSONArray row = (JSONArray) rowObject;
        result.add(Officials.newBuilder().setOfficialId(row.get(0) == null ? -1 : (Long) row.get(0))
                .setOfficialFirstName(row.get(1) == null ? "" : (String) row.get(1))
                .setOfficialLastName(row.get(2) == null ? "" : (String) row.get(2))
                .setOfficialJerseyNum(row.get(3) == null ? -1 : Long.parseLong(row.get(3).toString().trim()))
                .build());/*from  w w w .j av  a 2s . co m*/
    }
    return result;
}

From source file:co.mcme.animations.animations.MCMEAnimation.java

public static MCMEAnimation createInstance(File configFile) throws IOException, ParseException {
    JSONParser parser = new JSONParser();
    Object obj = parser.parse(new FileReader(configFile));
    JSONObject conf = (JSONObject) obj;
    String animationType = (String) conf.get("type");

    if (animationType.equals("one-time")) {
        OneTimeAnimation result = new OneTimeAnimation(configFile);
        return result;
    } else if (animationType.equals("two-way")) {
        TwoWayAnimation result = new TwoWayAnimation(configFile);
        return result;
    } else if (animationType.equals("loop")) {
        LoopAnimation result = new LoopAnimation(configFile);
        return result;
    } else {/*w  w  w. j a v a2s .  c om*/
        return null;
    }
}

From source file:gov.nasa.jpl.xdata.nba.impoexpo.parse.ParseUtil.java

public static SeasonSeries parseSeasonSeries(JSONObject jsonObject) {
    JSONArray resultSets = (JSONArray) jsonObject.get("resultSets");
    JSONObject infoObject = (JSONObject) resultSets.get(2);
    JSONArray rowSet = (JSONArray) infoObject.get("rowSet");
    JSONArray row = (JSONArray) rowSet.get(0);
    long seriesId = Long.parseLong(row.get(0).toString().trim());
    long homeTeamId = (Long) row.get(1);
    long visitorTeamId = (Long) row.get(2);
    String seriesDateEst = (String) row.get(3);
    long homeTeamWins = (Long) row.get(4);
    long homeTeamLosses = (Long) row.get(5);
    String seriesLeader = (String) row.get(6);
    return SeasonSeries.newBuilder().setGameSeasonSeriesId(seriesId).setSeasonSeriesHomeTeamId(homeTeamId)
            .setSeasonSeriesVisitorTeamId(visitorTeamId).setGameSeasonSeriesDateEst(seriesDateEst)
            .setHomeTeamWins(homeTeamWins).setHomeTeamLosses(homeTeamLosses).setSeriesLeader(seriesLeader)
            .build();/* w  w w .  j a  va  2  s .  c  om*/
}

From source file:com.raphfrk.craftproxyclient.net.auth.AuthManager.java

public static String getUsername() {
    if (loginDetails == null) {
        return null;
    }/* ww w.j  a  va2 s.c o  m*/
    JSONObject profile = (JSONObject) loginDetails.get("selectedProfile");

    return (String) profile.get("name");
}

From source file:gov.nasa.jpl.xdata.nba.impoexpo.parse.ParseUtil.java

public static List<LineScore> parseLineScore(JSONObject jsonObject) {
    JSONArray resultSets = (JSONArray) jsonObject.get("resultSets");
    JSONObject infoObject = (JSONObject) resultSets.get(1);
    JSONArray rowSet = (JSONArray) infoObject.get("rowSet");
    List<LineScore> result = new ArrayList<LineScore>();
    for (int i = 0; i < 2; i++) {
        JSONArray row = (JSONArray) rowSet.get(i);
        result.add(LineScore.newBuilder().setGameLineScoreDateEst((String) row.get(0))
                .setGameLineScoreSequence((Long) row.get(1))
                .setGameLineScoreId(Long.parseLong((String) row.get(2))).setLineScoreTeamId((Long) row.get(3))
                .setLineScoreTeamAbbreviation((String) row.get(4)).setTeamCityName((String) row.get(5))
                .setTeamWinsLosses((String) row.get(6)).setPtsQtr1((Long) row.get(7))
                .setPtsQtr2((Long) row.get(8)).setPtsQtr3((Long) row.get(9)).setPtsQtr4((Long) row.get(10))
                .setPtsOt1((Long) row.get(11)).setPtsOt2((Long) row.get(12)).setPtsOt3((Long) row.get(13))
                .setPtsOt4((Long) row.get(14)).setPtsOt5((Long) row.get(15)).setPtsOt6((Long) row.get(16))
                .setPtsOt7((Long) row.get(17)).setPtsOt8((Long) row.get(18)).setPtsOt9((Long) row.get(19))
                .setPtsOt10((Long) row.get(20)).setLineScorePts((Long) row.get(21)).build());
    }//w w  w .  j a v a 2 s . co m
    return result;
}

From source file:gov.nasa.jpl.xdata.nba.impoexpo.parse.ParseUtil.java

public static List<InactivePlayers> parseInactivePlayers(JSONObject jsonObject) {
    JSONArray resultSets = (JSONArray) jsonObject.get("resultSets");
    JSONObject inactivePlayersObject = (JSONObject) resultSets.get(9);
    JSONArray rowSet = (JSONArray) inactivePlayersObject.get("rowSet");
    List<InactivePlayers> result = new ArrayList<InactivePlayers>();
    for (Object rowObject : rowSet) {
        JSONArray row = (JSONArray) rowObject;
        result.add(InactivePlayers.newBuilder()
                .setInactivePlayersPlayerId(row.get(0) == null ? -1 : (Long) row.get(0))
                .setInactivePlayersFirstName(row.get(1) == null ? "" : (String) row.get(1))
                .setInactivePlayersLastName(row.get(2) == null ? "" : (String) row.get(2))
                .setInactivePlayersJerseyNum(
                        row.get(3) == null ? -1 : Long.parseLong(row.get(3).toString().trim()))
                .setInactivePlayersTeamId(row.get(4) == null ? -1 : (Long) row.get(4))
                .setInactivePLayersTeamCity(row.get(5) == null ? "" : (String) row.get(5))
                .setInactivePlayersTeamName(row.get(6) == null ? "" : (String) row.get(6))
                .setInactivePlayersTeamAbbreviation(row.get(7) == null ? "" : (String) row.get(7)).build());
    }//from   w  w w  . ja v  a2s  .  co m
    return result;
}

From source file:gov.nasa.jpl.xdata.nba.impoexpo.parse.ParseUtil.java

public static List<OtherStats> parseOtherStats(JSONObject jsonObject) {
    JSONArray resultSets = (JSONArray) jsonObject.get("resultSets");
    JSONObject infoObject = (JSONObject) resultSets.get(6);
    JSONArray rowSet = (JSONArray) infoObject.get("rowSet");
    List<OtherStats> result = new ArrayList<OtherStats>();
    for (Object rowObject : rowSet) {
        JSONArray row = (JSONArray) rowObject;
        result.add(OtherStats.newBuilder()
                .setLeagueId(row.get(0) == null ? -1 : Long.parseLong(row.get(0).toString().trim()))
                .setSeasonId(row.get(1) == null ? -1 : Long.parseLong(row.get(1).toString().trim()))
                .setOtherStatsTeamId(row.get(2) == null ? -1 : (Long) row.get(2))
                .setOtherStatsTeamAbbreviation(row.get(3) == null ? "" : (String) row.get(3))
                .setOtherStatsTeamCity(row.get(4) == null ? "" : (String) row.get(4))
                .setPtsPaint(row.get(5) == null ? -1 : (Long) row.get(5))
                .setPts2ndChance(row.get(6) == null ? -1 : (Long) row.get(6))
                .setPtsFb(row.get(7) == null ? -1 : (Long) row.get(7))
                .setLargestLead(row.get(8) == null ? -1 : (Long) row.get(8))
                .setLeadChanges(row.get(9) == null ? -1 : (Long) row.get(9))
                .setTimesTied(row.get(10) == null ? -1 : (Long) row.get(10)).build());
    }//from  ww w .  j  ava2  s. co  m
    return result;
}

From source file:com.github.lgi2p.obirs.utils.JSONConverter.java

/**
 * {"log": "", "annotations" : [{ "text": "uranium", "startpos": 723,
 * "endpos":730, "uris":["http://www.cea.fr/ontotoxnuc#Uranium"] },{ "text":
 * "protein", "startpos": 1837, "endpos":1845,
 * "uris":["http://www.cea.fr/ontotoxnuc#Proteine"] },{ "text": "plant",
 * "startpos": 4661, "endpos":4666,/*from  w ww .  j  av a  2 s. c  o  m*/
 * "uris":["http://www.cea.fr/ontotoxnuc#Plante"] }]}
 *
 * @param jsonQuery
 * @return
 * @throws ParseException
 * @throws Exception
 */
protected static String toJSONindexFormat(int id, String title, String content, String href)
        throws ParseException, Exception {

    URIFactory f = URIFactoryMemory.getSingleton();

    content = content.replace("\n", "").replace("\r", "");
    Object obj = new JSONParser().parse(content);
    JSONObject jsonObject = (JSONObject) obj;
    JSONArray annotations = (JSONArray) jsonObject.get("annotations");

    Set<URI> concepts = new HashSet<URI>();

    if (annotations != null) {
        Iterator<JSONObject> iterator = annotations.iterator();
        while (iterator.hasNext()) {
            JSONObject concept = iterator.next();
            JSONArray uris = (JSONArray) concept.get("uris");
            for (int i = 0; i < uris.size(); i++) {
                concepts.add(f.getURI((String) uris.get(i)));
            }
        }

    }

    String urisAsString = "";
    for (URI u : concepts) {
        if (!urisAsString.isEmpty()) {
            urisAsString += ",";
        }
        urisAsString += "\"" + u.stringValue() + "\"";
    }
    return "{\"id\":\"" + id + "\",\"title\":\"" + title + "\",\"conceptIds\":[" + urisAsString
            + "],\"href\":\"" + href + "\"}";
}

From source file:gov.nasa.jpl.xdata.nba.impoexpo.parse.ParseUtil.java

public static LastMeeting parseLastMeeting(JSONObject jsonObject) {
    JSONArray resultSets = (JSONArray) jsonObject.get("resultSets");
    JSONObject infoObject = (JSONObject) resultSets.get(3);
    JSONArray rowSet = (JSONArray) infoObject.get("rowSet");
    JSONArray row = (JSONArray) rowSet.get(0);
    long gameLastMeetingId = Long.parseLong(row.get(0).toString().trim());
    long lastGameId = Long.parseLong(row.get(1).toString().trim());
    String lastGameDate = (String) row.get(2);
    long lastGameHomeTeamId = (Long) row.get(3);
    String lastGameHomeTeamCity = (String) row.get(4);
    String lastGameHomeTeamName = (String) row.get(5);
    String lastGameHomeTeamAbbreviation = (String) row.get(6);
    long lastGameHomeTeamPoints = (Long) row.get(7);
    long lastGameVisitorId = (Long) row.get(8);
    String lastGameVisitorCity = (String) row.get(9);
    String lastGameVisitorName = (String) row.get(10);
    String lastGameVisitorCity1 = (String) row.get(11);
    long lastGameVisitorPoints = (Long) row.get(12);
    return LastMeeting.newBuilder().setGameLastMeetingId(gameLastMeetingId).setLastGameId(lastGameId)
            .setLastGameDateEst(lastGameDate).setLastGameHomeTeamId(lastGameHomeTeamId)
            .setLastGameHomeTeamCity(lastGameHomeTeamCity).setLastGameHomeTeamName(lastGameHomeTeamName)
            .setLastGameHomeTeamAbbreviation(lastGameHomeTeamAbbreviation)
            .setLastGameHomeTeamPoints(lastGameHomeTeamPoints).setLastGameHomeTeamId(lastGameHomeTeamId)
            .setLastGameVisitorTeamId(lastGameVisitorId).setLastGameVisitorTeamCity(lastGameVisitorCity)
            .setLastGameVisitorTeamName(lastGameVisitorName).setLastGameVisitorTeamCity1(lastGameVisitorCity1)
            .setLastGameVisitorTeamPoints(lastGameVisitorPoints).build();
}

From source file:it.polimi.logging.LogMessageUtils.java

public static JSONObject getStatus(String message) {

    JSONObject jsonMsg;
    JSONParser parser = new JSONParser();

    try {/* w w w . ja  v  a2  s. com*/
        jsonMsg = (JSONObject) parser.parse(message);
        JSONObject status = (JSONObject) jsonMsg.get(JsonStrings.STATUS);
        return status;
    } catch (ParseException e) {
        e.printStackTrace();
    }

    return null;
}