Example usage for org.json JSONObject JSONObject

List of usage examples for org.json JSONObject JSONObject

Introduction

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

Prototype

public JSONObject() 

Source Link

Document

Construct an empty JSONObject.

Usage

From source file:org.rapidandroid.activity.FormCreator.java

private void saveState() {
    // TODO Auto-generated method stub
    // this.d/*from ww  w .  j  a  v  a 2s. c om*/
    JSONObject savedstate = new JSONObject();
    EditText etxFormName = (EditText) findViewById(R.id.etx_formname);
    EditText etxFormPrefix = (EditText) findViewById(R.id.etx_formprefix);
    EditText etxDescription = (EditText) findViewById(R.id.etx_description);
    //      ListView lsv = (ListView) findViewById(R.id.lsv_createfields);

    try {
        savedstate.put(STATE_FORMNAME, etxFormName.getText().toString());
        savedstate.put(STATE_PREFIX, etxFormPrefix.getText().toString());
        savedstate.put(STATE_DESC, etxDescription.getText().toString());
        savedstate.put(STATE_PARSER, mChosenParser.getName());

        if (mCurrentFields != null) {
            int numFields = this.mCurrentFields.size();
            for (int i = 0; i < numFields; i++) {
                Field f = mCurrentFields.get(i);

                JSONObject fieldobj = new JSONObject();

                fieldobj.put(AddField.ResultConstants.RESULT_KEY_FIELDNAME, f.getName());
                fieldobj.put(AddField.ResultConstants.RESULT_KEY_DESCRIPTION, f.getDescription());
                fieldobj.put(AddField.ResultConstants.RESULT_KEY_FIELDTYPE_ID,
                        ((SimpleFieldType) f.getFieldType()).getId());
                savedstate.put("Field" + i, fieldobj);
            }
        }

        getIntent().putExtra("current_form", savedstate.toString());

    } catch (JSONException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
        Log.d("FormCreator", e1.getMessage());
    }
}

From source file:net.jmhertlein.mcanalytics.api.request.PasswordResetRequest.java

@Override
public String toJSON() {
    JSONObject ret = new JSONObject();
    ret.put("id", getRequestId());
    ret.put("type", RequestType.PASSWORD_RESET);
    ret.put("username", username);
    ret.put("old", oldPass);
    ret.put("new", newPass);
    return ret.toString();
}

From source file:com.liferay.mobile.android.v62.assetcategory.AssetCategoryService.java

public JSONObject addCategory(String title, long vocabularyId, JSONObjectWrapper serviceContext)
        throws Exception {
    JSONObject _command = new JSONObject();

    try {//from  w  w  w.j  a v  a2 s . c om
        JSONObject _params = new JSONObject();

        _params.put("title", checkNull(title));
        _params.put("vocabularyId", vocabularyId);
        mangleWrapper(_params, "serviceContext", "com.liferay.portal.service.ServiceContext", serviceContext);

        _command.put("/assetcategory/add-category", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getJSONObject(0);
}

From source file:com.liferay.mobile.android.v62.assetcategory.AssetCategoryService.java

public JSONObject addCategory(long parentCategoryId, JSONObject titleMap, JSONObject descriptionMap,
        long vocabularyId, JSONArray categoryProperties, JSONObjectWrapper serviceContext) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*from  w  ww  . ja  va  2  s.c  o m*/
        JSONObject _params = new JSONObject();

        _params.put("parentCategoryId", parentCategoryId);
        _params.put("titleMap", checkNull(titleMap));
        _params.put("descriptionMap", checkNull(descriptionMap));
        _params.put("vocabularyId", vocabularyId);
        _params.put("categoryProperties", checkNull(categoryProperties));
        mangleWrapper(_params, "serviceContext", "com.liferay.portal.service.ServiceContext", serviceContext);

        _command.put("/assetcategory/add-category", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getJSONObject(0);
}

From source file:com.liferay.mobile.android.v62.assetcategory.AssetCategoryService.java

public void deleteCategories(JSONArray categoryIds) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*from ww w . ja v a  2  s .  com*/
        JSONObject _params = new JSONObject();

        _params.put("categoryIds", checkNull(categoryIds));

        _command.put("/assetcategory/delete-categories", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    session.invoke(_command);
}

From source file:com.liferay.mobile.android.v62.assetcategory.AssetCategoryService.java

public JSONArray deleteCategories(JSONArray categoryIds, JSONObjectWrapper serviceContext) throws Exception {
    JSONObject _command = new JSONObject();

    try {//from w ww .j  av a 2s .c  o m
        JSONObject _params = new JSONObject();

        _params.put("categoryIds", checkNull(categoryIds));
        mangleWrapper(_params, "serviceContext", "com.liferay.portal.service.ServiceContext", serviceContext);

        _command.put("/assetcategory/delete-categories", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getJSONArray(0);
}

From source file:com.liferay.mobile.android.v62.assetcategory.AssetCategoryService.java

public void deleteCategory(long categoryId) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*from  w w  w .  j  a v a2  s . c o m*/
        JSONObject _params = new JSONObject();

        _params.put("categoryId", categoryId);

        _command.put("/assetcategory/delete-category", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    session.invoke(_command);
}

From source file:com.liferay.mobile.android.v62.assetcategory.AssetCategoryService.java

public JSONArray getCategories(String className, long classPK) throws Exception {
    JSONObject _command = new JSONObject();

    try {/* w ww. ja v  a  2 s. c  o m*/
        JSONObject _params = new JSONObject();

        _params.put("className", checkNull(className));
        _params.put("classPK", classPK);

        _command.put("/assetcategory/get-categories", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getJSONArray(0);
}

From source file:com.liferay.mobile.android.v62.assetcategory.AssetCategoryService.java

public JSONObject getCategory(long categoryId) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*from  w ww.  jav  a2 s .c o m*/
        JSONObject _params = new JSONObject();

        _params.put("categoryId", categoryId);

        _command.put("/assetcategory/get-category", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getJSONObject(0);
}

From source file:com.liferay.mobile.android.v62.assetcategory.AssetCategoryService.java

public JSONArray getChildCategories(long parentCategoryId) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*from  w ww  .ja  va 2  s.  c  o  m*/
        JSONObject _params = new JSONObject();

        _params.put("parentCategoryId", parentCategoryId);

        _command.put("/assetcategory/get-child-categories", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getJSONArray(0);
}