Java tutorial
package com.mp.gw2api.base; import java.util.logging.Level; import java.util.logging.Logger; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; /* * Copyright (C) 2016 Hero * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ /** * * @author Hero */ public class GW2APIDataList implements IGW2APIData { public long[] maps; /*! Load the map list from Json Text */ @Override public void LoadFromJsonText(String text) { JSONParser parser = new JSONParser(); JSONObject json; try { //Parse json array JSONArray ja = (JSONArray) parser.parse(text); //Create object array to retrieve data maps = new long[ja.size()]; if (ja != null) { for (int i = 0; i < ja.size(); i++) { maps[i] = (long) ja.get(i); } } } catch (ParseException ex) { Logger.getLogger(GW2APIDataList.class.getName()).log(Level.SEVERE, null, ex); maps = null; } } }