Here are the examples of the java api com.google.gson.JsonObject.add() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1736 Examples
19
Source : ACMECommand.java
with MIT License
from porunov
with MIT License
from porunov
private void postExecution() {
result.add("status", getGson().toJsonTree((error) ? "error" : "ok"));
}
19
Source : DocumentDeserializationTest.java
with GNU Affero General Public License v3.0
from OvercastNetwork
with GNU Affero General Public License v3.0
from OvercastNetwork
void jsonIn(String key, Object value) {
jsonObject.add(key, gson.toJsonTree(value));
}
19
Source : JWTToken.java
with Eclipse Public License 1.0
from OpenLiberty
with Eclipse Public License 1.0
from OpenLiberty
/**
* check com.ibm.ws.security.openidconnect.token.PayloadConstants for keys
*
* @param key
* @param listString
*/
public void setHeaderProp(String key, List<String> listString) {
JsonArray jsonArray = handleList(listString);
_headerObj.add(key, jsonArray);
}
19
Source : JWTToken.java
with Eclipse Public License 1.0
from OpenLiberty
with Eclipse Public License 1.0
from OpenLiberty
/**
* check com.ibm.ws.security.openidconnect.token.PayloadConstants for keys
*
* @param key
* @param listString
*/
public void setPayloadProp(String key, List<String> listString) {
JsonArray jsonArray = handleList(listString);
_payloadObj.add(key, jsonArray);
}
19
Source : QuerySerializer.java
with Apache License 2.0
from mitre
with Apache License 2.0
from mitre
private void serializeMultiFieldComponents(MultiFieldQuery query, JsonObject obj) {
obj.add("qf", serializeFeature(query.getQF()));
if (query.getTie() != null) {
obj.add(TIE, serializeFeature(query.getTie()));
}
if (query.getQueryOperator().getOperator() != QueryOperator.OPERATOR.UNSPECIFIED) {
obj.add("q.op", serializeQueryOperator(query.getQueryOperator()));
}
updateJsonQueryStringName(obj, query);
}
19
Source : QuerySerializer.java
with Apache License 2.0
from mitre
with Apache License 2.0
from mitre
private JsonElement serializeQuery(Query query) {
JsonObject jsonObject = new JsonObject();
if (query instanceof EDisMaxQuery) {
jsonObject.add(EDISMAX, serializeEDisMax((EDisMaxQuery) query));
} else if (query instanceof DisMaxQuery) {
jsonObject.add(DISMAX, serializeDisMax((DisMaxQuery) query));
} else if (query instanceof LuceneQuery) {
jsonObject.add(LUCENE, serializeLucene((LuceneQuery) query));
} else if (query instanceof TermsQuery) {
jsonObject.add(TERMS, serializeTerms((TermsQuery) query));
} else if (query instanceof TermQuery) {
jsonObject.add(TERM, serializeTerm((TermQuery) query));
} else if (query instanceof MultiMatchQuery) {
jsonObject.add(MULTI_MATCH, serializeMultiMatchQuery((MultiMatchQuery) query));
} else if (query instanceof BooleanQuery) {
jsonObject.add(BOOL, serializeBoolean((BooleanQuery) query));
} else if (query instanceof BoostingQuery) {
jsonObject.add(BOOSTING, serializeBoosting((BoostingQuery) query));
} else {
throw new IllegalArgumentException("I'm sorry, I don't yet support: " + query.getClreplaced());
}
return jsonObject;
}
19
Source : QuerySerializer.java
with Apache License 2.0
from mitre
with Apache License 2.0
from mitre
private JsonElement serializeTerms(TermsQuery query) {
JsonObject obj = new JsonObject();
obj.add("terms", stringListJsonArr(query.getTerms()));
obj.add("field", new JsonPrimitive(query.getField()));
return obj;
}
19
Source : VanillaProfiles.java
with GNU Lesser General Public License v2.1
from ImpactDevelopment
with GNU Lesser General Public License v2.1
from ImpactDevelopment
private JsonObject getProfilesList() {
if (!json.has("profiles")) {
json.add("profiles", new JsonObject());
}
if (!json.get("profiles").isJsonObject()) {
throw new RuntimeException(String.format("\"profiles\" is not an object in \"%s\"", launcherProfiles.toAbsolutePath().toString()));
}
return json.get("profiles").getAsJsonObject();
}
19
Source : BetterJsonObject.java
with GNU Lesser General Public License v3.0
from HyperiumClient
with GNU Lesser General Public License v3.0
from HyperiumClient
/**
* Adds another BetterJsonObject into this one
*
* @param key the key
* @param object the object to add
*/
public BetterJsonObject add(String key, BetterJsonObject object) {
if (key != null)
data.add(key, object.data);
return this;
}
19
Source : ScriptScoreBuilder.java
with Apache License 2.0
from fengbindev
with Apache License 2.0
from fengbindev
public void addParam(String key, String value) {
params.add(key, new JsonPrimitive(value));
}
19
Source : ScriptScoreBuilder.java
with Apache License 2.0
from fengbindev
with Apache License 2.0
from fengbindev
public void addParam(String key, Number value) {
params.add(key, new JsonPrimitive(value));
}
19
Source : ScriptScoreBuilder.java
with Apache License 2.0
from fengbindev
with Apache License 2.0
from fengbindev
public void addParam(String key, Boolean value) {
params.add(key, new JsonPrimitive(value));
}
19
Source : SqsMessage.java
with Apache License 2.0
from ExpediaGroup
with Apache License 2.0
from ExpediaGroup
public void setTableLocation(String location) {
apiaryEventMessageJsonObject.add(EVENT_TABLE_LOCATION_KEY, new JsonPrimitive(location));
}
19
Source : JsonObjectBuilder.java
with BSD 3-Clause "New" or "Revised" License
from dhis2
with BSD 3-Clause "New" or "Revised" License
from dhis2
public JsonObjectBuilder addObject(String property, JsonObjectBuilder obj) {
jsonObject.add(property, obj.build());
return this;
}
18
Source : JsonStatsMetric.java
with Apache License 2.0
from yugabyte
with Apache License 2.0
from yugabyte
public synchronized JsonObject getJson() {
JsonObject json = new JsonObject();
json.add("latency", latency.getJson());
json.add("throughput", throughput.getJson());
return json;
}
18
Source : ContractMock.java
with Apache License 2.0
from yggdrash
with Apache License 2.0
from yggdrash
public void createMock() {
mock.addProperty("name", name);
mock.addProperty("symbol", symbol);
mock.addProperty("property", property);
mock.addProperty("description", description);
mock.add("contracts", contracts);
mock.addProperty("timestamp", timeStamp);
mock.add("consensus", consensus);
mock.addProperty("governanceContract", governanceContract);
}
18
Source : ContractMock.java
with Apache License 2.0
from yggdrash
with Apache License 2.0
from yggdrash
public void createSampleContract() {
sampleContract.addProperty("contractVersion", contractVersion);
sampleContract.add("init", contractInit);
sampleContract.addProperty("description", contractDescription);
sampleContract.addProperty("name", contractName);
sampleContract.addProperty("isSystem", contractIsSystem);
}
18
Source : HeartBeatComponent.java
with Apache License 2.0
from wso2
with Apache License 2.0
from wso2
private static JsonObject createChangeNotification() {
JsonObject changeNotification = new JsonObject();
JsonArray deployedArtifacts = ArtifactDeploymentListener.getDeployedArtifacts();
JsonArray undeployedArtifacts = ArtifactDeploymentListener.getUndeployedArtifacts();
changeNotification.add(DEPLOYED_ARTIFACTS, deployedArtifacts);
changeNotification.add(UNDEPLOYED_ARTIFACTS, undeployedArtifacts);
return changeNotification;
}
18
Source : JsonObjectBuilder.java
with MIT License
from Vrekt
with MIT License
from Vrekt
public JsonObjectBuilder add(String key, JsonElement value) {
jsonObject.add(key, value);
return this;
}
18
Source : Analytics.java
with MIT License
from unascribed
with MIT License
from unascribed
private static String processExtra(Map<String, String> extra) {
JsonObject extraJson = new JsonObject();
int i = 1;
for (Map.Entry<String, String> en : extra.entrySet()) {
JsonArray arr = new JsonArray();
arr.add(en.getKey());
arr.add(en.getValue());
extraJson.add(Integer.toString(i), arr);
i++;
}
return new Gson().toJson(extraJson);
}
18
Source : TwasiWebsocketAnswer.java
with MIT License
from Twasi
with MIT License
from Twasi
public static JsonElement warn(String message) {
JsonObject ob = new JsonObject();
ob.add("status", new JsonPrimitive("warn"));
ob.add("message", new JsonPrimitive(message));
return ob;
}
18
Source : TwasiWebsocketAnswer.java
with MIT License
from Twasi
with MIT License
from Twasi
public static JsonElement success() {
JsonObject ob = new JsonObject();
ob.add("status", new JsonPrimitive("success"));
return ob;
}
18
Source : YamlUtils.java
with Apache License 2.0
from tomzo
with Apache License 2.0
from tomzo
public static void addOptionalObject(JsonObject jsonObject, Map<String, Object> yamlSource, String jsonField, String yamlFieldName) {
Object obj = getOptionalObject(yamlSource, yamlFieldName);
if (obj != null)
jsonObject.add(jsonField, new Gson().toJsonTree(obj));
}
18
Source : TaskTransform.java
with Apache License 2.0
from tomzo
with Apache License 2.0
from tomzo
private void addOnCancel(JsonObject taskJson, Map<String, Object> taskMap) {
Object on_cancel = taskMap.get(YAML_TASK_CANCEL_FIELD);
if (on_cancel != null) {
if (!(on_cancel instanceof Map))
throw new YamlConfigException("expected on_cancel task to be a hash");
JsonObject onCancelJson = transform(on_cancel);
taskJson.add(JSON_TASK_CANCEL_FIELD, onCancelJson);
}
}
18
Source : JobTransform.java
with Apache License 2.0
from tomzo
with Apache License 2.0
from tomzo
private void addTasks(JsonObject jobJson, Map<String, Object> jobMap) {
Object tasksObj = jobMap.get(YAML_JOB_TASKS_FIELD);
if (tasksObj == null)
throw new YamlConfigException("tasks are required in a job");
JsonArray tasksJson = new JsonArray();
List<Object> taskList = (List<Object>) tasksObj;
addTasks(taskList, tasksJson);
jobJson.add(JSON_JOB_TASKS_FIELD, tasksJson);
}
18
Source : CommonTestUtils.java
with Apache License 2.0
from tmobile
with Apache License 2.0
from tmobile
public static JsonArray getAllHitsArrayJson() {
JsonObject jsonObject = new JsonObject();
jsonObject.add("_source", getAllSourceJson());
JsonArray array = new JsonArray();
array.add(jsonObject);
return array;
}
18
Source : CommonTestUtils.java
with Apache License 2.0
from tmobile
with Apache License 2.0
from tmobile
public static JsonArray getHitsArrayJson() {
JsonObject jsonObject = new JsonObject();
jsonObject.add("_source", getSourceJson());
JsonArray array = new JsonArray();
array.add(jsonObject);
return array;
}
18
Source : FeatureTransformer.java
with MIT License
from TerraForged
with MIT License
from TerraForged
@Override
public JsonElement toJson(BiomeContext<?> context) {
JsonObject root = new JsonObject();
for (Map.Entry<JsonPrimitive, JsonPrimitive> entry : valueTransformers.entrySet()) {
root.add(entry.getKey().getreplacedtring(), entry.getValue());
}
for (Map.Entry<String, JsonElement> entry : keyTransformers.entrySet()) {
root.add(entry.getKey(), entry.getValue());
}
return root;
}
18
Source : TarsSamplerBase.java
with BSD 3-Clause "New" or "Revised" License
from TarsCloud
with BSD 3-Clause "New" or "Revised" License
from TarsCloud
public JsonObject getResponseBody(JsonObject[] retArgs) {
JsonObject retJson = new JsonObject();
String[] names = getParameterNames();
for (int i = 0; i < names.length; i++) {
retJson.add(names[i], retArgs[i]);
}
return retJson;
}
18
Source : TarsSamplerBase.java
with BSD 3-Clause "New" or "Revised" License
from TarsCloud
with BSD 3-Clause "New" or "Revised" License
from TarsCloud
public JsonObject getRequestBody() {
JsonObject retJson = new JsonObject();
String[] names = getParameterNames();
JsonObject[] values = getRequestParameters();
for (int i = 0; i < names.length; i++) {
retJson.add(names[i], values[i]);
}
return retJson;
}
18
Source : BungecordMetrics.java
with Apache License 2.0
from Skungee
with Apache License 2.0
from Skungee
/**
* Collects the data and sends it afterwards.
*/
private void submitData() {
final JsonObject data = getServerData();
final JsonArray pluginData = new JsonArray();
// Search for all other bStats Metrics clreplacedes to get their plugin data
for (Object metrics : knownMetricsInstances) {
try {
Object plugin = metrics.getClreplaced().getMethod("getPluginData").invoke(metrics);
if (plugin instanceof JsonObject) {
pluginData.add((JsonObject) plugin);
}
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {
}
}
data.add("plugins", pluginData);
// Create a new thread for the connection to the bStats server
new Thread(new Runnable() {
@Override
public void run() {
try {
// Send the data
sendData(data);
} catch (Exception e) {
// Something went wrong! :(
if (logFailedRequests) {
plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats!", e);
}
}
}
}).start();
}
18
Source : JsonRpcResponse.java
with Apache License 2.0
from Sixt
with Apache License 2.0
from Sixt
public JsonObject toJson() {
JsonObject retval = new JsonObject();
retval.add(ID_FIELD, id);
retval.add(ERROR_FIELD, error);
retval.add(RESULT_FIELD, result);
return retval;
}
18
Source : AttributeTraitBuilder.java
with MIT License
from SilentChaos512
with MIT License
from SilentChaos512
@Override
public JsonObject serialize() {
if (this.modifiers.isEmpty()) {
throw new IllegalStateException("Attribute trait '" + this.traitId + "' has no modifiers");
}
JsonObject json = super.serialize();
JsonObject modsJson = new JsonObject();
this.modifiers.forEach(((key, mods) -> {
JsonArray array = new JsonArray();
mods.forEach(e -> array.add(e.serialize()));
modsJson.add(key, array);
}));
json.add("attribute_modifiers", modsJson);
return json;
}
18
Source : MaterialDisplay.java
with MIT License
from SilentChaos512
with MIT License
from SilentChaos512
public JsonObject serialize() {
JsonObject json = new JsonObject();
this.map.forEach((key, layerList) -> json.add(key.toString(), layerList.serialize()));
return json;
}
18
Source : JsonObjectBuilder.java
with MIT License
from seansegal
with MIT License
from seansegal
public JsonObjectBuilder add(String key, JsonElement element) {
j.add(key, element);
return this;
}
18
Source : Json_Settings.java
with GNU General Public License v3.0
from salimkanoun
with GNU General Public License v3.0
from salimkanoun
// permet de creer le JSON avant de l'ecrire
public void construireIndex() {
// On rentre les valeurs contenue dans les variables
index.addProperty("Name", orthancName);
index.addProperty("StorageDirectory", storageDirectory);
index.addProperty("IndexDirectory", indexDirectory);
index.addProperty("StorageCompression", StorageCompression);
index.addProperty("MaximumStorageSize", MaximumStorageSize);
index.addProperty("MaximumPatientCount", MaximumPatientCount);
index.add("LuaScripts", luaFolder);
index.add("Plugins", pluginsFolder);
index.addProperty("ConcurrentJobs", ConcurrentJobs);
index.addProperty("HttpServerEnabled", HttpServerEnabled);
index.addProperty("HttpPort", HttpPort);
index.addProperty("HttpDescribeErrors", HttpDescribeErrors);
index.addProperty("HttpCompressionEnabled", HttpCompressionEnabled);
index.addProperty("DicomServerEnabled", DicomServerEnabled);
index.addProperty("DicomAet", DicomAet);
index.addProperty("DicomCheckCalledAet", DicomCheckCalledAet);
index.addProperty("DicomPort", DicomPort);
index.addProperty("DefaultEncoding", DefaultEncoding);
index.addProperty("DeflatedTransferSyntaxAccepted", DeflatedTransferSyntaxAccepted);
index.addProperty("JpegTransferSyntaxAccepted", JpegTransferSyntaxAccepted);
index.addProperty("Jpeg2000TransferSyntaxAccepted", Jpeg2000TransferSyntaxAccepted);
index.addProperty("JpegLosslessTransferSyntaxAccepted", JpegLosslessTransferSyntaxAccepted);
index.addProperty("JpipTransferSyntaxAccepted", JpipTransferSyntaxAccepted);
index.addProperty("Mpeg2TransferSyntaxAccepted", Mpeg2TransferSyntaxAccepted);
index.addProperty("RleTransferSyntaxAccepted", RleTransferSyntaxAccepted);
index.addProperty("UnknownSopClreplacedAccepted", UnknownSopClreplacedAccepted);
index.addProperty("DicomScpTimeout", DicomScpTimeout);
index.addProperty("RemoteAccessAllowed", RemoteAccessAllowed);
index.addProperty("SslEnabled", SslEnabled);
index.addProperty("SslCertificate", SslCertificate);
index.addProperty("AuthenticationEnabled", AuthenticationEnabled);
index.add("RegisteredUsers", users);
index.add("DicomModalities", dicomNode);
index.addProperty("DicomAlwaysAllowEcho", dicomAlwaysAllowEcho);
index.addProperty("DicomAlwaysAllowStore", DicomAlwaysStore);
index.addProperty("DicomCheckModalityHost", CheckModalityHost);
index.addProperty("DicomScuTimeout", DicomScuTimeout);
index.add("OrthancPeers", orthancPeer);
index.addProperty("HttpProxy", HttpProxy);
index.addProperty("HttpTimeout", HttpTimeout);
index.addProperty("HttpsVerifyPeers", HttpsVerifyPeers);
index.addProperty("HttpsCACertificates", HttpsCACertificates);
index.add("UserMetadata", userMetadata);
index.add("UserContentType", contentType);
index.addProperty("StableAge", StableAge);
index.addProperty("StrictAetComparison", StrictAetComparison);
index.addProperty("StoreMD5ForAttachments", StoreMD5ForAttachments);
index.addProperty("LimitFindResults", LimitFindResults);
index.addProperty("LimitFindInstances", LimitFindInstances);
index.addProperty("LimitJobs", LimitJobs);
index.addProperty("LogExportedResources", LogExportedResources);
index.addProperty("KeepAlive", KeepAlive);
index.addProperty("StoreDicom", StoreDicom);
index.addProperty("DicomreplacedociationCloseDelay", DicomreplacedociationCloseDelay);
index.addProperty("QueryRetrieveSize", QueryRetrieveSize);
index.addProperty("CaseSensitivePN", CaseSensitivePN);
index.addProperty("LoadPrivateDictionary", LoadPrivateDictionary);
index.add("Dictionary", dictionary);
index.addProperty("SynchronousCMove", SynchronousCMove);
index.addProperty("JobsHistorySize", JobsHistorySize);
index.addProperty("DicomModalitiesInDatabase", dicomModalitiesInDb);
index.addProperty("OrthancPeersInDatabase", orthancPeerInDb);
index.addProperty("OverwriteInstances", overwriteInstances);
index.addProperty("MediaArchiveSize", mediaArchiveSize);
index.addProperty("StorageAccessOnFind", storageAccessOnFind);
index.addProperty("HttpVerbose", httpVerbose);
index.addProperty("TcpNoDelay", tcpNoDelay);
index.addProperty("HttpThreadsCount", httpThreadsCount);
index.addProperty("SaveJobs", saveJobs);
index.addProperty("MetricsEnabled", metricsEnabled);
}
18
Source : N5FragmentSegmentAssignmentPersisterSerializer.java
with GNU General Public License v2.0
from saalfeldlab
with GNU General Public License v2.0
from saalfeldlab
@Override
public JsonElement serialize(N5FragmentSegmentreplacedignmentPersister src, Type type, JsonSerializationContext context) {
final JsonObject map = new JsonObject();
try {
map.add(N5_META_KEY, SerializationHelpers.serializeWithClreplacedInfo(N5Meta.fromReader(src.getWriter(), src.getDataset()), context));
} catch (ReflectionException e) {
throw new JsonParseException(e);
}
return map;
}
18
Source : N5FragmentSegmentAssignmentInitialLutSerializer.java
with GNU General Public License v2.0
from saalfeldlab
with GNU General Public License v2.0
from saalfeldlab
@Override
public JsonElement serialize(N5FragmentSegmentreplacedignmentInitialLut src, Type type, JsonSerializationContext context) {
final JsonObject map = new JsonObject();
map.add(N5_META_KEY, SerializationHelpers.serializeWithClreplacedInfo(src.getMeta(), context));
return map;
}
18
Source : CloudflareRequest.java
with Apache License 2.0
from robinbraemer
with Apache License 2.0
from robinbraemer
public CloudflareRequest body(String property, JsonElement value) {
body.add(checkNotNull(property, ERROR_INVALID_BODY), checkNotNull(value, ERROR_INVALID_BODY));
return this;
}
18
Source : FunctionApp.java
with Apache License 2.0
from redhat-developer-demos
with Apache License 2.0
from redhat-developer-demos
public static JsonObject main(JsonObject args) {
JsonObject response = new JsonObject();
response.add("response", args);
return response;
}
18
Source : ElasticSearchClient.java
with Apache License 2.0
from RBMHTechnology
with Apache License 2.0
from RBMHTechnology
public void bulkUpdate(List<JsonObject> updates, String docType) {
final Bulk.Builder bulkProcessor = new Bulk.Builder();
// prepare update actions
updates.forEach(u -> {
final String id = u.remove("_id").getreplacedtring();
final String index = u.remove("_index").getreplacedtring();
final JsonObject updateDoc = new JsonObject();
updateDoc.add("doc", u.getAsJsonObject());
final Update update = new Update.Builder(updateDoc.toString()).index(index).id(id).type(docType).build();
bulkProcessor.addAction(update);
});
final JestClient client = getElasticSearchClient();
try {
bulkUpdate(bulkProcessor, 0, client);
} catch (InterruptedException e) {
log.error("Error executing bulk update: {}", e.getMessage(), e);
throw new RuntimeException("Error executing bulk update: " + e.getMessage(), e);
}
}
18
Source : KcaTimerWidget.java
with GNU General Public License v3.0
from qly5213
with GNU General Public License v3.0
from qly5213
public void updateData(Context context) {
KcaDBHelper dbHelper = new KcaDBHelper(context, null, KCANOTIFY_DB_VERSION);
KcaUtils.setDefaultGameData(context, dbHelper);
KcaApiData.setDBHelper(dbHelper);
widgetData = new JsonObject();
widgetData.add("deckport", dbHelper.getJsonArrayValue(DB_KEY_DECKPORT));
widgetData.add("ndock", dbHelper.getJsonArrayValue(DB_KEY_NDOCKDATA));
widgetData.add("kdock", dbHelper.getJsonArrayValue(DB_KEY_KDOCKDATA));
dbHelper.close();
}
18
Source : KcaDeckInfo.java
with GNU General Public License v3.0
from qly5213
with GNU General Public License v3.0
from qly5213
public JsonArray getDeckListInfo(JsonArray deckPortData, int deckid, String request_list, String kc_request_list) {
JsonArray deckListInfo = new JsonArray();
int deckSize = deckPortData.size();
if (deckid < deckSize) {
JsonArray deckShipIdList = (JsonArray) ((JsonObject) deckPortData.get(deckid)).get("api_ship");
for (int i = 0; i < deckShipIdList.size(); i++) {
JsonObject data = new JsonObject();
int shipId = deckShipIdList.get(i).getAsInt();
if (shipId != -1) {
int shipKcId = -1;
JsonObject shipData = getUserShipDataById(shipId, request_list);
data.add("user", shipData);
if (shipData.has("api_ship_id")) {
shipKcId = shipData.get("api_ship_id").getAsInt();
} else if (shipData.has("ship_id")) {
shipKcId = shipData.get("ship_id").getAsInt();
}
if (shipKcId != -1) {
data.add("kc", getKcShipDataById(shipKcId, kc_request_list));
deckListInfo.add(data);
}
}
}
}
return deckListInfo;
}
18
Source : DiscordRpc.java
with MIT License
from PSNRigner
with MIT License
from PSNRigner
private void registerForEvent(String name) {
JsonObject jsonObject = new JsonObject();
jsonObject.add("cmd", new JsonPrimitive("SUBSCRIBE"));
jsonObject.add("evt", new JsonPrimitive(name));
jsonObject.add("nonce", new JsonPrimitive(String.valueOf(this.nonce++)));
byte[] bytes = jsonObject.toString().getBytes();
if (this.sendQueue.offer(bytes))
this.signalIoActivity();
}
18
Source : DiscordRpc.java
with MIT License
from PSNRigner
with MIT License
from PSNRigner
/**
* Respond to a join / spectate request
*
* @param userId ID of user who requested to join
* @param reply Reply, can be either YES, NO, or IGNORE
*/
public void respond(String userId, DiscordReply reply) {
if (this.rpcConnection == null || !this.rpcConnection.isOpen())
return;
JsonObject jsonObject = new JsonObject();
jsonObject.add("cmd", new JsonPrimitive(reply == DiscordReply.YES ? "SEND_ACTIVITY_JOIN_INVITE" : "CLOSE_ACTIVITY_JOIN_REQUEST"));
JsonObject args = new JsonObject();
args.add("user_id", new JsonPrimitive(userId));
jsonObject.add("args", args);
jsonObject.add("nonce", new JsonPrimitive(String.valueOf(this.nonce++)));
byte[] bytes = jsonObject.toString().getBytes();
if (this.sendQueue.offer(bytes))
this.signalIoActivity();
}
18
Source : RestTest.java
with Apache License 2.0
from polypheny
with Apache License 2.0
from polypheny
private JsonObject getTestRow() {
JsonObject row = new JsonObject();
row.add("test.resttest.tbigint", new JsonPrimitive(1234L));
row.add("test.resttest.tboolean", new JsonPrimitive(true));
row.add("test.resttest.tdate", new JsonPrimitive(LocalDate.of(2020, 7, 23).format(DateTimeFormatter.ISO_LOCAL_DATE)));
row.add("test.resttest.tdecimal", new JsonPrimitive(new BigDecimal("123.45")));
row.add("test.resttest.tdouble", new JsonPrimitive(1.999999));
row.add("test.resttest.tinteger", new JsonPrimitive(9876));
row.add("test.resttest.treal", new JsonPrimitive(0.3333));
row.add("test.resttest.tsmallint", new JsonPrimitive(45));
row.add("test.resttest.ttime", new JsonPrimitive(LocalTime.of(12, 5, 5).format(DateTimeFormatter.ISO_LOCAL_TIME)));
row.add("test.resttest.ttimestamp", new JsonPrimitive(LocalDateTime.of(2020, 7, 23, 12, 5, 5).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)));
row.add("test.resttest.ttinyint", new JsonPrimitive(22));
row.add("test.resttest.tvarchar", new JsonPrimitive("hallo"));
return row;
}
18
Source : KafkaCluster.java
with Apache License 2.0
from pinterest
with Apache License 2.0
from pinterest
public JsonElement toJson() {
JsonObject json = new JsonObject();
JsonArray jsonBrokers = new JsonArray();
json.add("brokers", jsonBrokers);
List<KafkaBroker> result = new ArrayList<>();
synchronized (brokers) {
for (KafkaBroker broker : brokers.values()) {
jsonBrokers.add(broker.toJson());
}
}
return json;
}
18
Source : KafkaBroker.java
with Apache License 2.0
from pinterest
with Apache License 2.0
from pinterest
@Deprecated
public JsonElement toJson() {
// Return a JSON representation of a Kafka Broker. Sadly, not everything can be trivially added.
JsonObject json = new JsonObject();
json.add("brokerId", gson.toJsonTree(brokerId));
json.add("brokerName", gson.toJsonTree(brokerName));
json.add("rackId", gson.toJsonTree(rackId));
json.add("bytesInPerSecLimit", gson.toJsonTree(bytesInPerSecLimit));
json.add("bytesOutPerSecLimit", gson.toJsonTree(bytesOutPerSecLimit));
json.add("maxBytesOut", gson.toJsonTree(getMaxBytesOut()));
json.add("maxBytesIn", gson.toJsonTree(getMaxBytesIn()));
return json;
}
18
Source : AbstractRequestBuilder.java
with MIT License
from Petersoj
with MIT License
from Petersoj
/**
* Appends a {@link JsonElement} property to {@link #buildBody()}.
*
* @param boreplacedy the body key
* @param bodyValue the {@link JsonElement} body value
*/
public void appendJSONBodyJSONProperty(String boreplacedy, JsonElement bodyValue) {
bodyJsonObject.add(boreplacedy, bodyValue);
}
18
Source : EndPortals.java
with MIT License
from paulevsGitch
with MIT License
from paulevsGitch
private static JsonObject makeDefault(File file) {
JsonObject jsonObject = new JsonObject();
JsonFactory.storeJson(file, jsonObject);
JsonArray array = new JsonArray();
jsonObject.add("portals", array);
array.add(makeDefault().toJson());
JsonFactory.storeJson(file, jsonObject);
return jsonObject;
}
See More Examples