use of org.json_voltpatches.JSONStringer in project voltdb by VoltDB.
the class DDLCompiler method convertToJSONObject.
private static String convertToJSONObject(AbstractExpression expr) throws JSONException {
JSONStringer stringer = new JSONStringer();
stringer.object();
expr.toJSONString(stringer);
stringer.endObject();
return stringer.toString();
}
use of org.json_voltpatches.JSONStringer in project voltdb by VoltDB.
the class DDLCompiler method convertToJSONArray.
protected static String convertToJSONArray(List<AbstractExpression> exprs) throws JSONException {
JSONStringer stringer = new JSONStringer();
stringer.array();
for (AbstractExpression abstractExpression : exprs) {
stringer.object();
abstractExpression.toJSONString(stringer);
stringer.endObject();
}
stringer.endArray();
return stringer.toString();
}
use of org.json_voltpatches.JSONStringer in project voltdb by VoltDB.
the class InstanceId method serializeToJSONObject.
public JSONObject serializeToJSONObject() throws JSONException {
JSONStringer stringer = new JSONStringer();
stringer.object();
stringer.keySymbolValuePair("coord", m_coord);
stringer.keySymbolValuePair("timestamp", m_timestamp);
stringer.endObject();
return new JSONObject(stringer.toString());
}
use of org.json_voltpatches.JSONStringer in project voltdb by VoltDB.
the class AbstractTopology method topologyToJSON.
/////////////////////////////////////
//
// SERIALIZATION API
//
/////////////////////////////////////
public JSONObject topologyToJSON() throws JSONException {
JSONStringer stringer = new JSONStringer();
stringer.object();
stringer.keySymbolValuePair(TOPO_VERSION, version);
stringer.key(TOPO_HAGROUPS).array();
List<HAGroup> haGroups = hostsById.values().stream().map(h -> h.haGroup).distinct().collect(Collectors.toList());
for (HAGroup haGroup : haGroups) {
haGroup.toJSON(stringer);
}
stringer.endArray();
stringer.key(TOPO_PARTITIONS).array();
for (Partition partition : partitionsById.values()) {
partition.toJSON(stringer);
}
stringer.endArray();
stringer.key(TOPO_HOSTS).array();
for (Host host : hostsById.values()) {
host.toJSON(stringer);
}
stringer.endArray();
stringer.endObject();
return new JSONObject(stringer.toString());
}
use of org.json_voltpatches.JSONStringer in project voltdb by VoltDB.
the class SerializableException method toJSONString.
@Override
public String toJSONString() {
try {
JSONStringer js = new JSONStringer();
js.object();
js.keySymbolValuePair("type", getExceptionType().ordinal());
js.keySymbolValuePair("message", m_message);
js.endObject();
return js.toString();
} catch (Exception e) {
return "{ error: \"Unable to serialize exception.\" }";
}
}
Aggregations