Example usage for org.json.extension JSONConstructor endObject

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

Introduction

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

Prototype

JSONConstructor endObject() throws JSONException;

Source Link

Document

Ends an object.

Usage

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

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

    json.object();/*from   w w  w .j a  v a  2s. com*/
    if (errors == null && result == null && exception == null) {
        json.key("status").value("success");
    } else {
        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();
}