feat: update usage of JsonUtil

This commit is contained in:
Frank.R.Wu 2021-11-17 14:41:06 +08:00
parent 70c8313226
commit 2701f7286d
4 changed files with 9 additions and 9 deletions

View File

@ -1293,7 +1293,7 @@ public class ContractManager {
if (client.contractMeta.sigRequired) {
if (!request.verifySignature()) {
cr = new ContractResult(Status.Error, new JsonPrimitive("sign verified failed"));
rcb.onResult(JsonUtil.parseObject(cr));
rcb.onResult(JsonUtil.parseObjectAsJsonObject(cr));
return;
}
}
@ -1309,7 +1309,7 @@ public class ContractManager {
client.traffic += result.length();
client.contractStatus = ContractStatus.Executed;
JsonObject finalRet = JsonUtil.parseString(result);
JsonObject finalRet = JsonUtil.parseStringAsJsonObject(result);
if (client.getContractCopies() == 1) {
finalRet =
extractEventsFromContractResult(
@ -1368,7 +1368,7 @@ public class ContractManager {
client.traffic += result.length();
if (client.getContractCopies() == 1) {
extractEventsFromContractResult(ocb, JsonUtil.parseString(result), client, request, start);
extractEventsFromContractResult(ocb, JsonUtil.parseStringAsJsonObject(result), client, request, start);
}
chainOpener.writeContractResultToLocalAndLedger(
result, client, request, ocb, start, System.currentTimeMillis() - start);
@ -1552,7 +1552,7 @@ public class ContractManager {
new JsonPrimitive(
"Contract " + cr.getContractID() + " doesn't exists!!"));
}
rcb.onResult(JsonUtil.parseObject(result));
rcb.onResult(JsonUtil.parseObjectAsJsonObject(result));
}
@ -2170,7 +2170,7 @@ public class ContractManager {
if (null != client) {
try {
String ret = client.get.syncGet("", "suicide", "");
JsonObject jo = JsonUtil.parseString(ret);
JsonObject jo = JsonUtil.parseStringAsJsonObject(ret);
if (jo.has("cleanSub")) {
REvent msg =
new REvent(

View File

@ -265,7 +265,7 @@ public class EventBroker {
return null;
}
try {
JsonObject json = JsonUtil.parseString(content);
JsonObject json = JsonUtil.parseStringAsJsonObject(content);
String subscriber = json.get("subscriber").getAsString();
String handler = json.has("handler") ? json.get("handler").getAsString() : null;
if (null == subscriber || subscriber.isEmpty()) {

View File

@ -92,7 +92,7 @@ public class EventRecorder {
try {
if (json.startsWith("cp")) {
// create check point by the transaction and stop retrieving
JsonObject data = JsonUtil.parseString(json.substring(2));
JsonObject data = JsonUtil.parseStringAsJsonObject(json.substring(2));
cp.topic2cIds = JsonUtil.fromJson(data.get("topic2cIds").toString(), topic2cIdsType);
JsonObject id2Consumers = data.getAsJsonObject("id2Consumers");
for (String k : id2Consumers.keySet()) {
@ -183,7 +183,7 @@ public class EventRecorder {
String json = KeyValueRocksDBUtil.instance.getValue(dbName, TEMP_TOPIC_KEYS);
Map<String, Long> ret = new ConcurrentHashMap<>();
try {
JsonObject jo = JsonUtil.parseString(json);
JsonObject jo = JsonUtil.parseStringAsJsonObject(json);
for (String key : jo.keySet()) {
ret.put(key, jo.get(key).getAsLong());
}

View File

@ -42,7 +42,7 @@ public class WSClientConsumer implements IEventConsumer {
JsonObject ret = new JsonObject();
ret.addProperty("action", "onEvent");
ret.addProperty("status", "Success");
ret.add("data", JsonUtil.parseString(msg));
ret.add("data", JsonUtil.parseStringAsJsonObject(msg));
channel.writeAndFlush(new TextWebSocketFrame(ret.toString()));
}