mirror of
https://gitee.com/BDWare/cp.git
synced 2025-01-10 09:54:07 +00:00
feat: update usage of JsonUtil
This commit is contained in:
parent
dff61f8246
commit
4e7863b38b
@ -4,7 +4,6 @@ import com.google.gson.JsonObject;
|
|||||||
import org.apache.log4j.LogManager;
|
import org.apache.log4j.LogManager;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.bdware.sc.ContractProcess;
|
import org.bdware.sc.ContractProcess;
|
||||||
import org.bdware.sc.YJSPacker;
|
|
||||||
import org.bdware.sc.bean.Contract;
|
import org.bdware.sc.bean.Contract;
|
||||||
import org.bdware.sc.bean.ContractExecType;
|
import org.bdware.sc.bean.ContractExecType;
|
||||||
import org.bdware.sc.conn.ResultCallback;
|
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.FileUtil;
|
||||||
import org.bdware.sc.util.JsonUtil;
|
import org.bdware.sc.util.JsonUtil;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class DebugMain {
|
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);
|
static Logger LOGGER = LogManager.getLogger(DebugMain.class);
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@ -52,8 +36,8 @@ public class DebugMain {
|
|||||||
|
|
||||||
String url = String.format(urlFormat, config.agentHttpAddr, config.pubKey);
|
String url = String.format(urlFormat, config.agentHttpAddr, config.pubKey);
|
||||||
Map<String, Object> resp = HttpUtil.httpGet(url);
|
Map<String, Object> resp = HttpUtil.httpGet(url);
|
||||||
String data = (String)resp.get("response");
|
String data = (String) resp.get("response");
|
||||||
LOGGER.info(JsonUtil.toPrettyJson(JsonUtil.parseString(data)));
|
LOGGER.info(JsonUtil.toPrettyJson(JsonUtil.parseStringAsJsonObject(data)));
|
||||||
LOGGER.info("start done!");
|
LOGGER.info("start done!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +47,7 @@ public class DebugMain {
|
|||||||
Map<String, Object> resp = HttpUtil.httpGet(url);
|
Map<String, Object> resp = HttpUtil.httpGet(url);
|
||||||
String data = (String
|
String data = (String
|
||||||
) resp.get("response");
|
) resp.get("response");
|
||||||
JsonObject jsonObject = JsonUtil.parseString(data);
|
JsonObject jsonObject = JsonUtil.parseStringAsJsonObject(data);
|
||||||
config.cmi = jsonObject.get("cmi").getAsString();
|
config.cmi = jsonObject.get("cmi").getAsString();
|
||||||
config.dbPath = jsonObject.get("dbPath").getAsString();
|
config.dbPath = jsonObject.get("dbPath").getAsString();
|
||||||
config.cPort = jsonObject.get("cPort").getAsInt();
|
config.cPort = jsonObject.get("cPort").getAsInt();
|
||||||
@ -90,4 +74,18 @@ public class DebugMain {
|
|||||||
msg.arg = arg;
|
msg.arg = arg;
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class DebugConfig {
|
||||||
|
String script;
|
||||||
|
String agentHttpAddr;
|
||||||
|
String pubKey;
|
||||||
|
String privKey;
|
||||||
|
//AutoAppend
|
||||||
|
|
||||||
|
int port;
|
||||||
|
String cmi;
|
||||||
|
String dbPath;
|
||||||
|
int cPort;
|
||||||
|
Contract contract;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class HomomorphicDecryptHandler implements AnnotationHook {
|
|||||||
LOGGER.info("HomomorphicEncryptHandler--------------------------------3: " + privkey);
|
LOGGER.info("HomomorphicEncryptHandler--------------------------------3: " + privkey);
|
||||||
HomoVisitor.privateKey = privkey;
|
HomoVisitor.privateKey = privkey;
|
||||||
ret = getDecryptResult(homoDecryptConf, JsonUtil.parseObject(ret));
|
ret = getDecryptResult(homoDecryptConf, JsonUtil.parseObject(ret));
|
||||||
if (ret != null) {
|
if (null != ret) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ret = new JsonObject();
|
ret = new JsonObject();
|
||||||
|
@ -34,7 +34,7 @@ public class MemoryDump implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static MemoryDump loadFromStr(String memDump) {
|
public static MemoryDump loadFromStr(String memDump) {
|
||||||
JsonObject map = JsonUtil.parseString(memDump);
|
JsonObject map = JsonUtil.parseStringAsJsonObject(memDump);
|
||||||
MemoryDump ret = new MemoryDump();
|
MemoryDump ret = new MemoryDump();
|
||||||
for (Entry<String, JsonElement> entry : map.entrySet()) {
|
for (Entry<String, JsonElement> entry : map.entrySet()) {
|
||||||
long id = Long.parseLong(entry.getKey());
|
long id = Long.parseLong(entry.getKey());
|
||||||
|
Loading…
Reference in New Issue
Block a user