mirror of
https://gitee.com/BDWare/common
synced 2025-01-25 01:04:16 +00:00
support serialzable json
This commit is contained in:
parent
4047f03151
commit
1d3efbdb97
@ -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();
|
||||
}
|
||||
}
|
||||
|
25
src/main/entry/org/bdware/sc/bean/SerializableJson.java
Normal file
25
src/main/entry/org/bdware/sc/bean/SerializableJson.java
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user