Code example for JSONObject

Methods: getInt, getString, has

0
        int _bottom = 0;
 
        int _right = 0;
        int _left = 0;
 
        if (settings.has("src")) {
            try { 
                url = settings.getString("src");
                webView.loadUrl(url);
            } catch (JSONException e) {
                // default 
                // nothing to load 
            } 
        } 
 
        if (settings.has("height")) {
            try { 
                _height = settings.getInt("height");
            } catch (JSONException e) {
                // default 
                _height = ViewGroup.LayoutParams.MATCH_PARENT;
            } 
        } 
 
        if (settings.has("width")) {
            try { 
                _width = settings.getInt("width");
            } catch (JSONException e) {
                // default 
                _width = ViewGroup.LayoutParams.MATCH_PARENT;
            } 
        } 
 
        if (settings.has("x")) {
            try { 
                _x = settings.getInt("x");
            } catch (JSONException e) {
                // default 
                _x = 0;
            } 
        } 
 
        if (settings.has("y")) {
            try { 
                _y = settings.getInt("y");
            } catch (JSONException e) {
                // default 
                _y = 0;
            } 
        } 
 
        if (settings.has("left")) {
            try { 
                _left = _x + settings.getInt("left");
                _width -= _left;
            } catch (JSONException e) {
                // default 
                _left = _x;
            } 
        } 
 
        if (settings.has("right")) {
            try { 
                _right = settings.getInt("right");
                _width += _right;
            } catch (JSONException e) {
                // default 
                _right = 0;
            } 
        } 
 
        if (settings.has("top")) {
            try { 
                _top = _y + settings.getInt("top");
            } catch (JSONException e) {
                // default 
                _top = _y;
            } 
        } 
        if (settings.has("bottom")) {
            try { 
                _bottom = settings.getInt("bottom") - _y;
            } catch (JSONException e) {
                // default 
                _bottom = 0 - _y;
            } 
        }