Example usage for org.json JSONObject getLong

List of usage examples for org.json JSONObject getLong

Introduction

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

Prototype

public long getLong(String key) throws JSONException 

Source Link

Document

Get the long value associated with a key.

Usage

From source file:fr.pasteque.pos.customers.CustomerInfoExt.java

public CustomerInfoExt(JSONObject o) {
    super(null);/*w  w w  . ja v  a 2s. co  m*/
    if (!o.isNull("id")) {
        this.id = o.getString("id");
    }
    if (!o.isNull("number")) {
        this.taxid = o.getString("number");
    }
    if (!o.isNull("dispName")) {
        this.name = o.getString("dispName");
    }
    if (!o.isNull("key")) {
        this.searchkey = o.getString("key");
    }
    if (!o.isNull("custTaxId")) {
        this.taxcustomerid = o.getString("custTaxId");
    }
    if (!o.isNull("discountProfileId")) {
        this.discountProfileId = o.getInt("discountProfileId");
    }
    if (!o.isNull("notes")) {
        this.notes = o.getString("notes");
    }
    this.visible = o.getBoolean("visible");
    if (!o.isNull("card")) {
        this.card = o.getString("card");
    }
    if (!o.isNull("maxDebt")) {
        this.maxdebt = o.getDouble("maxDebt");
    }
    if (!o.isNull("debtDate")) {
        this.curdate = DateUtils.readSecTimestamp(o.getLong("debtDate"));
    }
    if (!o.isNull("currDebt")) {
        this.curdebt = o.getDouble("currDebt");
    }
    this.prepaid = o.getDouble("prepaid");
    if (!o.isNull("firstName")) {
        this.firstname = o.getString("firstName");
    }
    if (!o.isNull("lastName")) {
        this.lastname = o.getString("lastName");
    }
    if (!o.isNull("email")) {
        this.email = o.getString("email");
    }
    if (!o.isNull("phone1")) {
        this.phone = o.getString("phone1");
    }
    if (!o.isNull("phone2")) {
        this.phone2 = o.getString("phone2");
    }
    if (!o.isNull("fax")) {
        this.fax = o.getString("fax");
    }
    if (!o.isNull("addr1")) {
        this.address = o.getString("addr1");
    }
    if (!o.isNull("addr2")) {
        this.address2 = o.getString("addr2");
    }
    if (!o.isNull("zipCode")) {
        this.postal = o.getString("zipCode");
    }
    if (!o.isNull("city")) {
        this.city = o.getString("city");
    }
    if (!o.isNull("region")) {
        this.region = o.getString("region");
    }
    if (!o.isNull("country")) {
        this.country = o.getString("country");
    }
}

From source file:fr.immotronic.ubikit.pems.enocean.impl.item.data.EEP07201011DataImpl.java

public static EEP07201011DataImpl constructDataFromRecord(JSONObject lastKnownData) {
    if (lastKnownData == null)
        return new EEP07201011DataImpl(Mode.NO_ACTION, VanePosition.NO_ACTION, FanSpeed.NO_ACTION,
                RoomOccupancy.OCCUPIED, OnOffStatus.ON, 0, Disablement.NOT_DISABLED, Disablement.NOT_DISABLED,
                Disablement.NOT_DISABLED, Disablement.NOT_DISABLED, WindowsStatus.WINDOWS_CLOSED, AlarmState.OK,
                null);/*  w  ww  . j  a v a2s  .  c o  m*/

    try {
        Mode mode = Mode.valueOf(lastKnownData.getString("mode"));
        VanePosition vanePosition = VanePosition.valueOf(lastKnownData.getString("vanePosition"));
        FanSpeed fanSpeed = FanSpeed.valueOf(lastKnownData.getString("fanSpeed"));
        RoomOccupancy roomOccupancy = RoomOccupancy.valueOf(lastKnownData.getString("roomOccupancy"));
        OnOffStatus onOffStatus = OnOffStatus.valueOf(lastKnownData.getString("onOffStatus"));

        int errorCode = lastKnownData.getInt("errorCode");
        Disablement windowContactDisablement = Disablement.valueOf(lastKnownData.getString("windowContactD"));
        Disablement keyCardDisablement = Disablement.valueOf(lastKnownData.getString("keyCardD"));
        Disablement externalDisablement = Disablement.valueOf(lastKnownData.getString("externalD"));
        Disablement remoteControllerDisablement = Disablement
                .valueOf(lastKnownData.getString("remoteControllerD"));
        WindowsStatus windowContact = WindowsStatus.valueOf(lastKnownData.getString("windowContact"));
        AlarmState alarmState = AlarmState.valueOf(lastKnownData.getString("alarmState"));

        Date date = new Date(lastKnownData.getLong("date"));

        return new EEP07201011DataImpl(mode, vanePosition, fanSpeed, roomOccupancy, onOffStatus, errorCode,
                windowContactDisablement, keyCardDisablement, externalDisablement, remoteControllerDisablement,
                windowContact, alarmState, date);
    } catch (JSONException e) {
        Logger.error(LC.gi(), null,
                "constructDataFromRecord(): An exception while building a sensorData from a JSONObject SHOULD never happen. Check the code !",
                e);
        return new EEP07201011DataImpl(Mode.NO_ACTION, VanePosition.NO_ACTION, FanSpeed.NO_ACTION,
                RoomOccupancy.OCCUPIED, OnOffStatus.ON, 0, Disablement.NOT_DISABLED, Disablement.NOT_DISABLED,
                Disablement.NOT_DISABLED, Disablement.NOT_DISABLED, WindowsStatus.WINDOWS_CLOSED, AlarmState.OK,
                null);
    }
}

From source file:com.appdynamics.monitors.nginx.statsExtractor.UpstreamsStatsExtractor.java

private void collectMetrics(Map<String, String> upstreamsStats, String serverGroupName, JSONObject server) {

    String serverIp = server.getString("server");

    boolean backup = server.getBoolean("backup");
    upstreamsStats.put("upstreams|" + serverGroupName + "|" + serverIp + "|backup", backup ? "1" : "0");

    long weight = server.getLong("weight");
    upstreamsStats.put("upstreams|" + serverGroupName + "|" + serverIp + "|weight", String.valueOf(weight));

    // up?, down?, unavail?, or unhealthy?.
    String state = server.getString("state");
    int stateInt = -1;
    if ("up".equals(state)) {
        stateInt = 0;/*from  w  w  w  .j a v  a2s.co  m*/
    } else if ("down".equals(state)) {
        stateInt = 1;
    } else if ("unavail".equals(state)) {
        stateInt = 2;
    } else if ("unhealthy".equals(state)) {
        stateInt = 3;
    }
    upstreamsStats.put("upstreams|" + serverGroupName + "|" + serverIp + "|state", String.valueOf(stateInt));

    long active = server.getLong("active");
    upstreamsStats.put("upstreams|" + serverGroupName + "|" + serverIp + "|active", String.valueOf(active));

    if (server.has("max_conns")) {
        long maxConns = server.getLong("max_conns");
        upstreamsStats.put("upstreams|" + serverGroupName + "|" + serverIp + "|max_conns",
                String.valueOf(maxConns));
    }

    long requests = server.getLong("requests");
    upstreamsStats.put("upstreams|" + serverGroupName + "|" + serverIp + "|requests", String.valueOf(requests));

    JSONObject responses = server.getJSONObject("responses");
    long resp1xx = responses.getLong("1xx");
    upstreamsStats.put("upstreams|" + serverGroupName + "|" + serverIp + "|responses|1xx",
            String.valueOf(resp1xx));

    long resp2xx = responses.getLong("2xx");
    upstreamsStats.put("upstreams|" + serverGroupName + "|" + serverIp + "|responses|2xx",
            String.valueOf(resp2xx));

    long resp3xx = responses.getLong("3xx");
    upstreamsStats.put("upstreams|" + serverGroupName + "|" + serverIp + "|responses|3xx",
            String.valueOf(resp3xx));

    long resp4xx = responses.getLong("4xx");
    upstreamsStats.put("upstreams|" + serverGroupName + "|" + serverIp + "|responses|4xx",
            String.valueOf(resp4xx));

    long resp5xx = responses.getLong("5xx");
    upstreamsStats.put("upstreams|" + serverGroupName + "|" + serverIp + "|responses|5xx",
            String.valueOf(resp5xx));

    long respTotal = responses.getLong("total");
    upstreamsStats.put("upstreams|" + serverGroupName + "|" + serverIp + "|responses|total",
            String.valueOf(respTotal));

    long sent = server.getLong("sent");
    upstreamsStats.put("upstreams|" + serverGroupName + "|" + serverIp + "|sent", String.valueOf(sent));

    long received = server.getLong("received");
    upstreamsStats.put("upstreams|" + serverGroupName + "|" + serverIp + "|received", String.valueOf(received));

    long upstreamServerFails = server.getLong("fails");
    upstreamsStats.put("upstreams|" + serverGroupName + "|" + serverIp + "|fails",
            String.valueOf(upstreamServerFails));

    long unavail = server.getLong("unavail");
    upstreamsStats.put("upstreams|" + serverGroupName + "|" + serverIp + "|unavail", String.valueOf(unavail));

    JSONObject healthChecks = server.getJSONObject("health_checks");
    long checks = healthChecks.getLong("checks");
    upstreamsStats.put("upstreams|" + serverGroupName + "|" + serverIp + "|health_checks|checks",
            String.valueOf(checks));

    long healthCheckFails = healthChecks.getLong("fails");
    upstreamsStats.put("upstreams|" + serverGroupName + "|" + serverIp + "|health_checks|fails",
            String.valueOf(healthCheckFails));

    long unhealthy = healthChecks.getLong("unhealthy");
    upstreamsStats.put("upstreams|" + serverGroupName + "|" + serverIp + "|health_checks|unhealthy",
            String.valueOf(unhealthy));

    if (server.has("last_passed")) {
        boolean lastPassed = healthChecks.getBoolean("last_passed");
        upstreamsStats.put("upstreams|" + serverGroupName + "|" + serverIp + "|health_checks|last_passed",
                String.valueOf(lastPassed ? 0 : 1));
    }

    long downtime = server.getLong("downtime");
    upstreamsStats.put("upstreams|" + serverGroupName + "|" + serverIp + "|downtime", String.valueOf(downtime));

    long downstart = server.getLong("downstart");
    upstreamsStats.put("upstreams|" + serverGroupName + "|" + serverIp + "|downstart",
            String.valueOf(downstart));
}

From source file:edu.cwru.apo.Login.java

public void onRestRequestComplete(Methods method, JSONObject result) {
    if (method == Methods.login) {
        if (result != null) {
            try {
                String requestStatus = result.getString("requestStatus");
                if (requestStatus.compareTo("valid login") == 0) {
                    Auth.loggedIn = true;
                    Auth.Hmac.setCounter(result.getInt("counter"));
                    Auth.Hmac.setIncrement(result.getInt("increment"));
                    PhoneOpenHelper db = new PhoneOpenHelper(this);
                    if (database == null)
                        database = db.getWritableDatabase();
                    API api = new API(this);
                    if (!api.callMethod(Methods.phone, this, (String[]) null)) {
                        Toast msg = Toast.makeText(this, "Error: Calling phone", Toast.LENGTH_LONG);
                        msg.show();//from  www.  j av a 2  s. co  m
                    }

                } else if (requestStatus.compareTo("invalid username") == 0) {
                    Toast msg = Toast.makeText(getApplicationContext(), "Invalid username", Toast.LENGTH_LONG);
                    msg.show();
                } else if (requestStatus.compareTo("invalid login") == 0) {
                    Toast msg = Toast.makeText(getApplicationContext(), "Invalid username and/or password",
                            Toast.LENGTH_LONG);
                    msg.show();
                } else if (requestStatus.compareTo("no user") == 0) {
                    Toast msg = Toast.makeText(getApplicationContext(), "No username was provided",
                            Toast.LENGTH_LONG);
                    msg.show();
                } else {
                    Toast msg = Toast.makeText(getApplicationContext(), "Invalid requestStatus",
                            Toast.LENGTH_LONG);
                    msg.show();
                }
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        } else {
            Toast msg = Toast.makeText(getApplicationContext(),
                    "Could not contact web server.  Please check your connection", Toast.LENGTH_LONG);
            msg.show();
        }
    } else if (method == Methods.phone) {
        if (result != null) {
            try {
                String requestStatus = result.getString("requestStatus");
                if (requestStatus.compareTo("success") == 0) {
                    SharedPreferences.Editor editor = getSharedPreferences(APO.PREF_FILE_NAME, MODE_PRIVATE)
                            .edit();
                    editor.putLong("updateTime", result.getLong("updateTime"));
                    editor.commit();
                    int numbros = result.getInt("numBros");

                    if (numbros > 0) {
                        JSONArray caseID = result.getJSONArray("caseID");
                        JSONArray first = result.getJSONArray("first");
                        JSONArray last = result.getJSONArray("last");
                        JSONArray phone = result.getJSONArray("phone");
                        JSONArray family = result.getJSONArray("family");
                        ContentValues values;
                        for (int i = 0; i < numbros; i++) {
                            values = new ContentValues();
                            values.put("_id", caseID.getString(i));
                            values.put("first", first.getString(i));
                            values.put("last", last.getString(i));
                            values.put("phone", phone.getString(i));
                            values.put("family", family.getString(i));
                            database.replace("phoneDB", null, values);
                        }
                    }
                    Intent homeIntent = new Intent(Login.this, Home.class);
                    Login.this.startActivity(homeIntent);
                    finish();
                } else if (requestStatus.compareTo("timestamp invalid") == 0) {
                    Toast msg = Toast.makeText(this, "Invalid timestamp.  Please try again.",
                            Toast.LENGTH_LONG);
                    msg.show();
                } else if (requestStatus.compareTo("HMAC invalid") == 0) {
                    Toast msg = Toast.makeText(this,
                            "You have been logged out by the server.  Please log in again.", Toast.LENGTH_LONG);
                    msg.show();
                } else {
                    Toast msg = Toast.makeText(this, "Invalid requestStatus", Toast.LENGTH_LONG);
                    msg.show();
                }
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    } else {
        Toast msg = Toast.makeText(getApplicationContext(), "Invalid method callback", Toast.LENGTH_LONG);
        msg.show();
    }
}

From source file:com.gistlabs.mechanize.document.json.JsonTest.java

/**
 * Example from https://www.dropbox.com/developers/reference/api#account-info in dropbox.account.info.json
 *///  w w w. java 2 s .  com
@Test
public void testJsonParsing() throws Exception {
    JSONObject json = new JSONObject(new JSONTokener(
            new InputStreamReader(getClass().getResourceAsStream("impl/dropbox.account.info.json"))));
    assertNotNull(json);
    assertEquals(12345678, json.getLong("uid"));
}

From source file:com.parse.loginsample.layoutoverride.SampleProfileActivity.java

private void makeMeRequest() {
    GraphRequest request = GraphRequest.newMeRequest(AccessToken.getCurrentAccessToken(),
            new GraphRequest.GraphJSONObjectCallback() {
                @Override/*from  www  .  j a  v  a2  s  .  c  om*/
                public void onCompleted(JSONObject jsonObject, GraphResponse graphResponse) {
                    if (jsonObject != null) {
                        JSONObject userProfile = new JSONObject();

                        try {
                            userProfile.put("facebookId", jsonObject.getLong("id"));
                            userProfile.put("name", jsonObject.getString("name"));

                            if (jsonObject.getString("gender") != null)
                                userProfile.put("gender", jsonObject.getString("gender"));

                            //if (jsonObject.getString("email") != null)
                            //  userProfile.put("email", jsonObject.getString("email"));

                            // Save the user profile info in a user property
                            ParseUser currentUser = ParseUser.getCurrentUser();
                            currentUser.put("profile", userProfile);
                            currentUser.saveInBackground();

                            // Show the user info
                            //updateViewsWithProfileInfo();
                            //pull the swiping feature
                            //startSwipingFeature();
                        } catch (JSONException e) {
                            //Log.d(IntegratingFacebookTutorialApplication.TAG,"Error parsing returned user data. " + e);
                        }
                    } else if (graphResponse.getError() != null) {
                        switch (graphResponse.getError().getCategory()) {
                        case LOGIN_RECOVERABLE:
                            //Log.d(IntegratingFacebookTutorialApplication.TAG,"Authentication error: " + graphResponse.getError());
                            break;

                        case TRANSIENT:
                            Log.d(SampleApplication.TAG,
                                    "Transient error. Try again. " + graphResponse.getError());
                            break;

                        case OTHER:
                            //Log.d(IntegratingFacebookTutorialApplication.TAG,"Some other error: " + graphResponse.getError());
                            break;
                        }
                    }
                }
            });

    request.executeAsync();
}

From source file:com.nginious.http.serialize.JsonDeserializer.java

/**
 * Deserializes property with the specified name in the specified json object into a long.
 * //from  w w w. j  av  a 2s. c  o  m
 * @param object the json object
 * @param name the property name
 * @return the deserialized value or <code>0</code> if property doesn't exist
 * @throws SerializerException if unable to deserialize value
 */
protected long deserializeLong(JSONObject object, String name) throws SerializerException {
    try {
        if (object.has(name)) {
            return object.getLong(name);
        }

        return 0;
    } catch (JSONException e) {
        throw new SerializerException("Can't deserialize long property " + name, e);
    }
}

From source file:com.quantcast.measurement.service.QCPolicy.java

private boolean parsePolicy(String policyJsonString) {

    boolean successful = true;
    m_blacklist = null;/*  w ww.  j  av a  2s .co m*/
    m_salt = null;
    m_blackoutUntil = 0;
    m_sessionTimeout = null;

    if (!"".equals(policyJsonString)) {
        try {
            JSONObject policyJSON = new JSONObject(policyJsonString);

            if (policyJSON.has(BLACKLIST_KEY)) {
                try {
                    JSONArray blacklistJSON = policyJSON.getJSONArray(BLACKLIST_KEY);
                    if (blacklistJSON.length() > 0) {
                        if (m_blacklist == null) {
                            m_blacklist = new HashSet<String>(blacklistJSON.length());
                        }

                        for (int i = 0; i < blacklistJSON.length(); i++) {
                            m_blacklist.add(blacklistJSON.getString(i));
                        }
                    }
                } catch (JSONException e) {
                    QCLog.w(TAG, "Failed to parse blacklist from JSON.", e);
                }
            }

            if (policyJSON.has(SALT_KEY)) {
                try {
                    m_salt = policyJSON.getString(SALT_KEY);
                    if (USE_NO_SALT.equals(m_salt)) {
                        m_salt = null;
                    }
                } catch (JSONException e) {
                    QCLog.w(TAG, "Failed to parse salt from JSON.", e);
                }
            }

            if (policyJSON.has(BLACKOUT_KEY)) {
                try {
                    m_blackoutUntil = policyJSON.getLong(BLACKOUT_KEY);
                } catch (JSONException e) {
                    QCLog.w(TAG, "Failed to parse blackout from JSON.", e);
                }
            }

            if (policyJSON.has(SESSION_TIMEOUT_KEY)) {
                try {
                    m_sessionTimeout = policyJSON.getLong(SESSION_TIMEOUT_KEY);
                    if (m_sessionTimeout <= 0) {
                        m_sessionTimeout = null;
                    }
                } catch (JSONException e) {
                    QCLog.w(TAG, "Failed to parse session timeout from JSON.", e);
                }
            }
        } catch (JSONException e) {
            QCLog.w(TAG, "Failed to parse JSON from string: " + policyJsonString);
            successful = false;
        }
    }
    return successful;
}

From source file:org.apache.giraph.graph.BspServiceMaster.java

/**
 * Collect and aggregate the worker statistics for a particular superstep.
 *
 * @param superstep Superstep to aggregate on
 * @return Global statistics aggregated on all worker statistics
 *//*w  w w .  j a va 2  s. c o m*/
private GlobalStats aggregateWorkerStats(long superstep) {
    Class<? extends Writable> partitionStatsClass = masterGraphPartitioner.createPartitionStats().getClass();
    GlobalStats globalStats = new GlobalStats();
    // Get the stats from the all the worker selected nodes
    String workerFinishedPath = getWorkerFinishedPath(getApplicationAttempt(), superstep);
    List<String> workerFinishedPathList = null;
    try {
        workerFinishedPathList = getZkExt().getChildrenExt(workerFinishedPath, false, false, true);
    } catch (KeeperException e) {
        throw new IllegalStateException("aggregateWorkerStats: KeeperException", e);
    } catch (InterruptedException e) {
        throw new IllegalStateException("aggregateWorkerStats: InterruptedException", e);
    }

    allPartitionStatsList.clear();
    for (String finishedPath : workerFinishedPathList) {
        JSONObject workerFinishedInfoObj = null;
        try {
            byte[] zkData = getZkExt().getData(finishedPath, false, null);
            workerFinishedInfoObj = new JSONObject(new String(zkData));
            List<? extends Writable> writableList = WritableUtils.readListFieldsFromByteArray(
                    Base64.decode(workerFinishedInfoObj.getString(JSONOBJ_PARTITION_STATS_KEY)),
                    partitionStatsClass, getConfiguration());
            for (Writable writable : writableList) {
                globalStats.addPartitionStats((PartitionStats) writable);
                globalStats.addMessageCount(workerFinishedInfoObj.getLong(JSONOBJ_NUM_MESSAGES_KEY));
                allPartitionStatsList.add((PartitionStats) writable);
            }
        } catch (JSONException e) {
            throw new IllegalStateException("aggregateWorkerStats: JSONException", e);
        } catch (KeeperException e) {
            throw new IllegalStateException("aggregateWorkerStats: KeeperException", e);
        } catch (InterruptedException e) {
            throw new IllegalStateException("aggregateWorkerStats: InterruptedException", e);
        } catch (IOException e) {
            throw new IllegalStateException("aggregateWorkerStats: IOException", e);
        }
    }

    if (LOG.isInfoEnabled()) {
        LOG.info(
                "aggregateWorkerStats: Aggregation found " + globalStats + " on superstep = " + getSuperstep());
    }
    return globalStats;
}

From source file:com.repkap11.repcast.VideoProvider.java

public static List<MediaInfo> buildMedia(String url) throws JSONException {

    if (null != mediaList) {
        return mediaList;
    }/*from   ww w.j a  v  a  2 s  .co  m*/
    Map<String, String> urlPrefixMap = new HashMap<>();
    mediaList = new ArrayList<>();
    JSONObject jsonObj = new VideoProvider().parseUrl(url);
    JSONArray categories = jsonObj.getJSONArray(TAG_CATEGORIES);
    if (null != categories) {
        for (int i = 0; i < categories.length(); i++) {
            JSONObject category = categories.getJSONObject(i);
            urlPrefixMap.put(TAG_HLS, category.getString(TAG_HLS));
            urlPrefixMap.put(TAG_DASH, category.getString(TAG_DASH));
            urlPrefixMap.put(TAG_MP4, category.getString(TAG_MP4));
            urlPrefixMap.put(TAG_IMAGES, category.getString(TAG_IMAGES));
            urlPrefixMap.put(TAG_TRACKS, category.getString(TAG_TRACKS));
            category.getString(TAG_NAME);
            JSONArray videos = category.getJSONArray(TAG_VIDEOS);
            if (null != videos) {
                for (int j = 0; j < videos.length(); j++) {
                    String videoUrl = null;
                    String mimeType = null;
                    JSONObject video = videos.getJSONObject(j);
                    String subTitle = video.getString(TAG_SUBTITLE);
                    JSONArray videoSpecs = video.getJSONArray(TAG_SOURCES);
                    if (null == videoSpecs || videoSpecs.length() == 0) {
                        continue;
                    }
                    for (int k = 0; k < videoSpecs.length(); k++) {
                        JSONObject videoSpec = videoSpecs.getJSONObject(k);
                        if (TARGET_FORMAT.equals(videoSpec.getString(TAG_VIDEO_TYPE))) {
                            videoUrl = urlPrefixMap.get(TARGET_FORMAT) + videoSpec.getString(TAG_VIDEO_URL);
                            mimeType = videoSpec.getString(TAG_VIDEO_MIME);
                        }
                    }
                    if (videoUrl == null) {
                        continue;
                    }
                    String imageUrl = urlPrefixMap.get(TAG_IMAGES) + video.getString(TAG_THUMB);
                    String bigImageUrl = urlPrefixMap.get(TAG_IMAGES) + video.getString(TAG_IMG_780_1200);
                    String title = video.getString(TAG_TITLE);
                    String studio = video.getString(TAG_STUDIO);
                    int duration = video.getInt(TAG_DURATION);
                    List<MediaTrack> tracks = null;
                    if (video.has(TAG_TRACKS)) {
                        JSONArray tracksArray = video.getJSONArray(TAG_TRACKS);
                        if (tracksArray != null) {
                            tracks = new ArrayList<>();
                            for (int k = 0; k < tracksArray.length(); k++) {
                                JSONObject track = tracksArray.getJSONObject(k);
                                tracks.add(buildTrack(track.getLong(TAG_TRACK_ID),
                                        track.getString(TAG_TRACK_TYPE), track.getString(TAG_TRACK_SUBTYPE),
                                        urlPrefixMap.get(TAG_TRACKS) + track.getString(TAG_TRACK_CONTENT_ID),
                                        track.getString(TAG_TRACK_NAME), track.getString(TAG_TRACK_LANGUAGE)));
                            }
                        }
                    }
                    mediaList.add(buildMediaInfo(title, studio, subTitle, duration, videoUrl, mimeType,
                            imageUrl, bigImageUrl, tracks));
                }
            }
        }
    }
    return mediaList;
}