Example usage for org.json.extension JSONConstructor object

List of usage examples for org.json.extension JSONConstructor object

Introduction

In this page you can find the example usage for org.json.extension JSONConstructor object.

Prototype

JSONConstructor object() throws JSONException;

Source Link

Document

Starts an object.

Usage

From source file:de.cosmocode.palava.legacy.UpdateResult.java

@Override
public void encodeJSON(JSONConstructor json) throws JSONException {

    json.object();
    if (errors == null && result == null && exception == null) {
        json.key("status").value("success");
    } else {//  www .j  a va2 s . c  om
        json.key("status").value(isError() ? "error" : "success");
        if (errors != null)
            json.key("errors").value(errors);
        if (exception != null)
            json.key("exception").value(exception.toString());
        if (result != null) {
            json.key("result");
            if (result instanceof JSONEncoder) {
                final boolean objects = result instanceof NoObjectContext;
                if (objects)
                    json.object();
                ((JSONEncoder) result).encodeJSON(json);
                if (objects)
                    json.endObject();
            } else
                json.value(result);
        }
    }

    json.endObject();
}