support serialzable json

This commit is contained in:
CaiHQ 2022-04-07 18:49:57 +08:00
parent 4047f03151
commit 1d3efbdb97
2 changed files with 29 additions and 3 deletions

View File

@ -39,7 +39,8 @@ public class Contract extends SM2Verifiable implements Serializable {
private String hash;
private boolean stateful = true; // manifest可配置
private YjsType yjsType;
private JsonElement createParam;
private SerializableJson createParam;
public int getShardingId() {
return this.shardingId;
@ -228,10 +229,10 @@ public class Contract extends SM2Verifiable implements Serializable {
}
public void setCreateParam(JsonElement ele) {
createParam = ele;
createParam = new SerializableJson(ele);
}
public JsonElement getCreateParam() {
return createParam;
return createParam.getJsonElement();
}
}

View File

@ -0,0 +1,25 @@
package org.bdware.sc.bean;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import java.io.Serializable;
public class SerializableJson implements Serializable {
transient JsonElement jsonElement;
String content;
public SerializableJson(JsonElement jsonElement) {
this.jsonElement = jsonElement;
if (jsonElement != null)
content = jsonElement.toString();
}
public JsonElement getJsonElement() {
if (jsonElement != null)
return jsonElement;
if (content != null)
return JsonParser.parseString(content);
return null;
}
}