feat: update usage of JsonUtil

This commit is contained in:
Frank.R.Wu 2021-11-17 14:49:45 +08:00
parent dff61f8246
commit 4e7863b38b
3 changed files with 19 additions and 21 deletions

View File

@ -4,7 +4,6 @@ import com.google.gson.JsonObject;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.bdware.sc.ContractProcess;
import org.bdware.sc.YJSPacker;
import org.bdware.sc.bean.Contract;
import org.bdware.sc.bean.ContractExecType;
import org.bdware.sc.conn.ResultCallback;
@ -13,24 +12,9 @@ import org.bdware.sc.http.HttpUtil;
import org.bdware.sc.util.FileUtil;
import org.bdware.sc.util.JsonUtil;
import java.io.File;
import java.util.Map;
public class DebugMain {
static class DebugConfig {
String script;
String agentHttpAddr;
String pubKey;
String privKey;
//AutoAppend
int port;
String cmi;
String dbPath;
int cPort;
Contract contract;
}
static Logger LOGGER = LogManager.getLogger(DebugMain.class);
public static void main(String[] args) {
@ -53,7 +37,7 @@ public class DebugMain {
String url = String.format(urlFormat, config.agentHttpAddr, config.pubKey);
Map<String, Object> resp = HttpUtil.httpGet(url);
String data = (String) resp.get("response");
LOGGER.info(JsonUtil.toPrettyJson(JsonUtil.parseString(data)));
LOGGER.info(JsonUtil.toPrettyJson(JsonUtil.parseStringAsJsonObject(data)));
LOGGER.info("start done!");
}
@ -63,7 +47,7 @@ public class DebugMain {
Map<String, Object> resp = HttpUtil.httpGet(url);
String data = (String
) resp.get("response");
JsonObject jsonObject = JsonUtil.parseString(data);
JsonObject jsonObject = JsonUtil.parseStringAsJsonObject(data);
config.cmi = jsonObject.get("cmi").getAsString();
config.dbPath = jsonObject.get("dbPath").getAsString();
config.cPort = jsonObject.get("cPort").getAsInt();
@ -90,4 +74,18 @@ public class DebugMain {
msg.arg = arg;
return msg;
}
static class DebugConfig {
String script;
String agentHttpAddr;
String pubKey;
String privKey;
//AutoAppend
int port;
String cmi;
String dbPath;
int cPort;
Contract contract;
}
}

View File

@ -46,7 +46,7 @@ public class HomomorphicDecryptHandler implements AnnotationHook {
LOGGER.info("HomomorphicEncryptHandler--------------------------------3: " + privkey);
HomoVisitor.privateKey = privkey;
ret = getDecryptResult(homoDecryptConf, JsonUtil.parseObject(ret));
if (ret != null) {
if (null != ret) {
return ret;
}
ret = new JsonObject();

View File

@ -34,7 +34,7 @@ public class MemoryDump implements Serializable {
}
public static MemoryDump loadFromStr(String memDump) {
JsonObject map = JsonUtil.parseString(memDump);
JsonObject map = JsonUtil.parseStringAsJsonObject(memDump);
MemoryDump ret = new MemoryDump();
for (Entry<String, JsonElement> entry : map.entrySet()) {
long id = Long.parseLong(entry.getKey());