You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.
Let say there is deepstream client and JsonElement object jsonObj, then update record with jsonObj.
Record record = client.record.getRecord(recordName);
record.set(jsonObj);
Please refer to following code that copied from Record.java, as we can see, record.set(jsonObj) will invoke inner private method set(String path, Object value, boolean force), In runtime the last else condition will be matched. "element = this.gson.toJsonTree(value)" will construct JsonWriter, and write value into JsonWriter, then get JsonElement from JsonWriter. But the value is already JsonElement.
Following code is copied from Record.java
@ObjectiveCName("set:")
public Record set(JsonElement value) throws DeepstreamRecordDestroyedException {
return this.set((String)null, value, false);
}
@ObjectiveCName("set:value:force:")
private Record set(String path, Object value, boolean force) throws DeepstreamRecordDestroyedException {
this.throwExceptionIfDestroyed("set");
Object element;
if (value instanceof String) {
element = new JsonPrimitive((String)value);
} else if (value instanceof Number) {
element = new JsonPrimitive((Number)value);
} else if (value instanceof Boolean) {
element = new JsonPrimitive((Boolean)value);
} else {
element = this.gson.toJsonTree(value);
}
JsonElement object = this.path.get(path);
if (!force) {
if (object != null && object.equals(value)) {
return this;
}
if (path == null && this.data.equals(value)) {
return this;
}
}
Map<String, JsonElement> oldValues = this.beginChange();
this.path.set(path, (JsonElement)element);
this.data = this.path.getCoreElement();
this.sendUpdate(path, value);
this.completeChange(oldValues);
return this;
}
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Let say there is deepstream client and JsonElement object jsonObj, then update record with jsonObj.
Please refer to following code that copied from Record.java, as we can see, record.set(jsonObj) will invoke inner private method set(String path, Object value, boolean force), In runtime the last else condition will be matched. "element = this.gson.toJsonTree(value)" will construct JsonWriter, and write value into JsonWriter, then get JsonElement from JsonWriter. But the value is already JsonElement.
The text was updated successfully, but these errors were encountered: