fix + refactoring
This commit is contained in:
parent
2b14fa3634
commit
37cb35c99b
@ -133,15 +133,21 @@ public class JsonConverter {
|
||||
.build();
|
||||
}
|
||||
|
||||
public static PostAttributeMsg convertToAttributesProto(JsonElement jsonObject) throws JsonSyntaxException {
|
||||
if (jsonObject.isJsonObject()) {
|
||||
public static PostAttributeMsg convertToAttributesProto(JsonElement jsonElement) throws JsonSyntaxException {
|
||||
if (jsonElement.isJsonObject()) {
|
||||
PostAttributeMsg.Builder result = PostAttributeMsg.newBuilder();
|
||||
List<KeyValueProto> keyValueList = parseProtoValues(jsonObject.getAsJsonObject().getAsJsonObject("kv"));
|
||||
List<KeyValueProto> keyValueList = null;
|
||||
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||
if (jsonObject.has("kv") && jsonObject.has("scope")) {
|
||||
keyValueList = parseProtoValues(jsonObject.getAsJsonObject("kv"));
|
||||
result.setScope(jsonObject.getAsJsonPrimitive("scope").getAsString());
|
||||
} else {
|
||||
keyValueList = parseProtoValues(jsonObject);
|
||||
}
|
||||
result.addAllKv(keyValueList);
|
||||
result.setScope(jsonObject.getAsJsonObject().getAsJsonPrimitive("scope").getAsString());
|
||||
return result.build();
|
||||
} else {
|
||||
throw new JsonSyntaxException(CAN_T_PARSE_VALUE + jsonObject);
|
||||
throw new JsonSyntaxException(CAN_T_PARSE_VALUE + jsonElement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user